Log Level: The Java logging levels are used to control the logging output. They provide flexibility in enabling or disabling the various logging levels. This makes it possible to choose which logs will be displayed in the log files. With this, it is possible that the application running on the production has a different logging level than the same application running on the staging environment. Enabling one level of logging will make all higher-level logs enabled for printing in the log files. The following are the log levels and effective logging levels for the Java logging API:
Logger: The job of the Logger object is to log application messages. The application can create anonymous loggers, which are stored differently than in the Logger namespace. The application must be sure to keep a reference to the Logger object, as the Logger may get garbage collected at any point in time. The Logger object is associated with a parent Logger object, which is the nearest ancestor in Logger namespace. During the logging process, log messages are sent to Handler objects. The Handler objects forward the log messages to files, logs, or consoles. Every Logger object has a log level associated with it. It indicates the minimum level Logger will print logs for.
Handler: The responsibility of a Handler object is to get log messages from Logger objects, and send those log messages for printing to the appropriate destination. Examples include writing the log messages on the console, writing the log messages into a file, or writing the log messages to a network logging service. It is possible to enable or disable a Handler, which, in essence, stops printing those logs on the output medium.
Formatter: The log Formatter formats the log messages before writing them to the output medium. Java supports two types of Formatter objects: SimpleFormatter and XMLFormatter. The XMLFormatter object is required to include a head and tail around formatted records. It is also possible to create custom Formatter objects.
LogManager: LogManager is a singleton object, used to maintain a shared state of loggers and log services. Apart from this, the LogManager object manages logging properties and the Logger namespace. The LogManager object is instantiated while class initialization takes place. The object cannot be subsequently changed. LogManager reads the initial configuration from the lib/logging.properties file by default, which can be modified.