The Logger class, as the name suggests provides Logging functionality to jot down important points that you can use to output different kind of messages.
The messages can be of different severities aka levels;
LEVEL | SUMMARY |
UNKNOWN | Unknown messages are the unexpected or random messages and they should always be logged. |
FATAL | An error that was not handled and could lead to program crashing |
ERROR | An error that can be handled |
WARN | A warning |
INFO | Generic information about the usage from the code being executed |
DEBUG | Information that was deduced during debugging |
The order goes like;
debug < info < warn < error < fatal < unknown
They work as;
I production mode, you can set-up your Logger to output the messages which are either INFO messages or of the WARN level.
While in development mode, you would want to keep a tab on the program’s state and its status and therefore, you can set the Logger to the DEBUG level.
The interface is normally used as follows;
You also have the option to set an expiration date to the Log file. For ex, I want to keep the logs only for the current month. In that case I will be proceeding as follows:
And on an application level,
Happy logging !
Signing out,