Log4J Flashcards
What are the advantages to using a logging library?
A logging library (or logging framework) iscode that you embed into your application to create and manage log events. Logging libraries provide APIs for creating, structuring, formatting, and transmitting log events in a consistent way. Allows you to keep those logs and review them later.
What is log4j?
Apache Log4j is a Java-based logging utility. It is part of the Apache Logging Services.
What are the log4j main components?
Loggers, Appenders, and Layouts
What are Loggers?
The classes/entities that are responsible for recording log events and sending it to the appropriate appender. By default a root logger is provider, but you can also have class specific logger which are preferred.
What are Appenders?
Appenders are responsible for delivering the log event to their destination target.
What are layouts?
A layout is used by an appender to format a LogEvent into a form that meets the needs of whatever will be using the log event.
They are responsible for returning a byte array to be turned into a string using the appropriate layout.
What are the basic logging levels of log4j?
Trace, Debug, Info, Warning, Error, Fatal
Trace
Basically a debug message used to capture the flow throughout an application. It identifies a specific part for debugging.
Debug level in log4j
Identifying a general debugging event or logging some information helpful for debugging
info
Identifying a general event
Warning
dentifying an event that might lead to an error.
What is an Error in log4j?
Identifying an error that occurred in the application and that we can potentially recover from.
Fatal
Identifying a server that prevents the app from continuing its execution