Log4j Interview Questions and Answers
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. What are different types of logs?
Usually in any application there two types of logs.
1. Application server logs:- These are the logs configured at the application server level. for example in tomcat, we have log files called localhost.log, tomcat.log, catalina.log, stdout.log, sterr.log. all these logs are showing with default settings defined in logging.properites located in your tomcat installation folder/conf folder.
If you want custom settings, we have to change the different parameters in logging.properties in conf folder of tomcat directory.
2. Application logs:- We can define logging at each applicaiton level, For this we have to create log4j.xml or logging.properties in WEB-INF/classes folder.
Ques 2. In log4j how can you log into the database?
The log4j API provides the object org.apache.log4j.jdbc. JDBCAppender object can put logging information in a particular database.
Ques 3. Explain what does WARN and TRACE level indicates in log4j?
Log4j level WARN gives a warning about an unpredicted event to the user. The messages coming out of this level may not stop the progress of the system.
The TRACE level provides more detailed information than the DEBUG level, and it will stay at the top of the hierarchy.
Most helpful rated by users:
- What is Log4j?
- What are the different logging levels?
- Describe about logger levels in log4j.
- What are the three main components in log4j?
- What is the importance of logging applications?