0% found this document useful (0 votes)
28 views

Logger

Logging is used to store exceptions, information, and warnings during program execution to help with debugging. There are different log levels from severe to finest. Handlers are responsible for printing log messages to destinations like the console or files. Formatters format log records and are associated with handlers. Filters control which messages get logged by handlers or loggers by implementing a boolean isLoggable method. Configuration files allow loggers to be configured without changing code by using the LogManager class.

Uploaded by

Java Man
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Logger

Logging is used to store exceptions, information, and warnings during program execution to help with debugging. There are different log levels from severe to finest. Handlers are responsible for printing log messages to destinations like the console or files. Formatters format log records and are associated with handlers. Filters control which messages get logged by handlers or loggers by implementing a boolean isLoggable method. Configuration files allow loggers to be configured without changing code by using the LogManager class.

Uploaded by

Java Man
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Logging 

Logging is used to store exceptions, information, and warnings as messages that occur
during the execution of a program. Logging helps a programmer in the debugging
process of a program

1. Logger and Level

• SEVERE (highest level)


• WARNING
• INFO
• CONFIG
• FINE
• FINER
• FINEST (lowest level)

2. Handler

It is responsible for printing the log message at a target destination. The destination can
be a console or a file.

3. Formatter

A Formatter is used to format a LogRecord. Each handler is associated with a formatter. Java provides the Formatter as a
parent class of two in-built formatter’s i.e. SimpleFormatter and XMLFormatter

4. Filter
A  Filter  is an interface in  java.util.logging  package. It is used to control the messages to be logged
by the handler. Every  Logger  and  Handler  optionally can have a  Filter . The  Filter  has
a  isLoggable  method which returns a  boolean . Before publishing the message the  Logger  or
the  Handler  calls this method, if the method returns true the  LogRecord  gets publish else it gets ignored.

5. Configuration
You can provide configuration properties to a  Logger  using a configuration file. This helps you to
remove the configuration from the code and provides an easy way to re-configure whenever it is
required without changing the code again and again. This flexibility is provided by
the  LogManager  class.

You might also like