Log4j - Interview Questions and Answers for 'Log4j' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Log4j - Interview Questions and Answers for 'Log4j' - 21 question(s) found - Order By Newest

 Q1. What are some different logging levels for log4j ?Log4j
Ans. DEBUG
ERROR
ALL
WARN
INFO
FATAL
OFF
TRACE
TRACE_INT
WARN

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   log4j   log4j level   logging   error logging     Asked in 10 Companies


 Q2. How will you design a Log4j kind of framework.Log4j
 This question was recently asked at 'Software AG'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q3. What is the difference between log4j and java logging api.Log4j
Ans. log4j is by apache while java logging api is given by sun. log4j is more powerful,extensible and simple to use than java logging api.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q4. What is the difference between TimeBasedRollingPolicy and SizeBasedTriggeringPolicy within Log4j ? Can we use both together and What would that mean ?Log4j
Ans. TimeBasedRollingPolicy enables rolling of logs based on the time / days whereas SizeBasedTriggeringPolicy enables rolling of logs based on size cap.

Yes we can use both together. In that case Logs will be rolled in case any of the condition is met i.e after the interval or if the size is reached.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j  TimeBasedRollingPolicy  SizeBasedTriggeringPolicy


 Q5. What is the difference between RollingFile and RollingRandomAccessFile in log4j ?
Log4j
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     log4j  RollingFile  RollingRandomAccessFile


 Q6. How can we change the Log level for the application ?Log4j
Ans. By changing the Root Level within Log4j config.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q7. What is the default interval for TimeBasedTriggeringPolicy, if specified none like following

<Appenders>
<RollingFile name="RollingFile" fileName="logs/xyz.log" filePattern="logs/xyz-%d{MM-dd-yyyy}.log.gz"
ignoreExceptions="false">
      <TimeBasedTriggeringPolicy />
   </RollingFile>
</Appenders>
Log4j
Ans. 1 day

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q8. In following log4j configuration file, How should we change the logging level to WARN

<Configuration status="DEBUG">
<Appenders>
<RollingFile name="File" fileName="logs/xyz.log" filePattern="logs/xyz-%d{MM-dd-yyyy}.log.gz">
      <TimeBasedTriggeringPolicy />
   </RollingFile>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="File" />
</Root>
</Loggers>
</Configuration>
Log4j
Ans. We should change the root level from DEBUG to WARN

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q9. in the following log4j config file, How should we change the file name and format


<Configuration status="DEBUG">
<Appenders>
<RollingFile name="File" fileName="logs/xyz.log" filePattern="logs/xyz-%d{MM-dd-yyyy}.log.gz">
      <TimeBasedTriggeringPolicy />
   </RollingFile>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="File" />
</Root>
</Loggers>
</Configuration>
Log4j
Ans. We can specify the file name with fileName property within RollingFile. File name pattern for the rolled logs can be specified using filePattern property.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q10. In the following log4j config, What if we don't need rolling logs

<Configuration status="DEBUG">
<Appenders>
<RollingFile name="File" fileName="logs/xyz.log" filePattern="logs/xyz-%d{MM-dd-yyyy}.log.gz">
      <TimeBasedTriggeringPolicy />
   </RollingFile>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="File" />
</Root>
</Loggers>
</Configuration>
Log4j
Ans. We can change the appender from RollingFile to File or we can specify a new File appender and set that within AppenderRef

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q11. What are some of the Log4j appenders ?Log4j
Ans. https://logging.apache.org/log4j/2.x/manual/appenders.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q12. Can you organize following Log4j levels in hierarchy ?

WARN, DEBUG,INFO, ERROR
Log4j
Ans. DEBUG
INFO
WARN
ERROR

Root Log level of DEBUG will print all
Root Log Level of INFO will print INFO, WARN and ERROR
Root Log level of WARN will print WARN and ERROR
Root Log level of ERROR will print ERROR alone

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j levels hierarchy  Log4j


 Q13. What are the application Logging levels specified in your applications ? Log4j
Ans. In our Organization, the policy is to keep it WARN in production so as to reduce logging Noise. We use Info in Test environments.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q14. What should be the logging level while logging exceptions ?Log4j
Ans. It depends on how severe the exception is. If the exception is completely unexpected and breaks the request, It should be logged as ERROR or FATAL. If it's not expected but we can live with it and the application request continue in-spite of it, It should be WARN. If it's expected , it can be just INFO.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q15. What is the difference between INFO and DEBUG logging levels ?Log4j
Ans. Info Messages are something which we would like to see even if the application is in best of state. DEBUG messages are usually something that we would like to see while debugging some problem. DEBUG is lower level than Info. Any message logged with info gets printed if the Root level set is DEBUG.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j  Log4j levels


 Q16. What is the difference between DEBUG and TRACE logging levels ?Log4j
Ans. TRACE designates finer grained informational events than the DEBUG.TRACE is level lower than DEBUG.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j  DEBUG vs TRACE


 Q17. How to change the backup log directory using log4j ?Log4j
Ans. There is a property called "filePattern" within appender that regulates where the backed up files will be created for rolling logs. It actually contains the absolute path which can be modified to have backed up logs within some other directory.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j


 Q18. What does the property maxBackupIndex in Log4j means ?Log4j
Ans. It means that the app will only maintain these many backed up log files. Older backed up logs will be deleted.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Log4j


 Q19. Difference between log4j and slf4j ?Logging
 This question was recently asked at 'Y Media Labs'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     log4j vs slf4j     Asked in 1 Companies


 Q20. How can we switch log4j to print logging on console / file ?Log4j
Ans. By changing ConsoleAppender to a FileAppender and vice versa

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     log4j


 Q21. Have you ever done audit logging using log4j ?Log4j
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: