What is log4j?
Log4j is a simple, flexible and fast java based logging framework. It is thread safe and supports internationalization.
See more at: Log4j overview.
What are the components of log4j?
1. Logger: It is used to log the messages.
2. Appender: It is used to publish the logging information to the destination like file, database, console etc.
3. Layout: It is used to format logging information in different styles.
See more at: Log4j overview.
Explain Logger class?
Logger class provides the methods for logging process. We can use the getLogger() method to get the Logger object.
Syntax: public static Logger getLogger(String name);
Where name is the fully qualified class name.
See more at: Logger class.
What is purpose of ALL log level?
ALL − All levels including custom levels.
See more at: Logging levels in log4j.
What is purpose of DEBUG log level?
DEBUG − Designates fine-grained informational events that are most useful to debug an application.
See more at: Logging levels in log4j.
What is purpose of ERROR log level?
ERROR − Designates error events that might still allow the application to continue running.
See more at: Logging levels in log4j.
What is purpose of FATAL log level?
FATAL − Designates very severe error events that will presumably lead the application to abort.
See more at: Logging levels in log4j.
What is purpose of INFO log level?
INFO − Designates informational messages that highlight the progress of the application at coarse-grained level.
See more at: Logging levels in log4j.
What is purpose of OFF log level?
OFF − The highest possible rank and is intended to turn off logging.
See more at: Logging levels in log4j.
What is purpose of TRACE log level?
TRACE − Designates finer-grained informational events than the DEBUG.
See more at: Logging levels in log4j.
What is purpose of WARN log level?
WARN − Designates potentially harmful situations.
See more at: Logging levels in log4j.
How do Levels Works?
A log request of level p in a logger with level q is enabled if p >= q. This rule is at the heart of log4j. It assumes that levels are ordered. For the standard levels, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF. See more at: Logging levels in log4j.