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

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Log4J


   




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

 Q1. What are some different logging levels for log4j ?Log4j
Admin
info@buggybread.com
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


 Q2. What is the difference between TimeBasedRollingPolicy and SizeBasedTriggeringPolicy within Log4j ? Can we use both together and What would that mean ?Log4j2017-03-01 15:55:19

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


 Q3. What is the difference between RollingFile and RollingRandomAccessFile in log4j ?
Log4j2017-03-01 15:56:42

 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


 Q4. How can we change the Log level for the application ?Log4j2017-03-01 15:57:46

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     


 Q5. 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>
Log4j2017-03-01 16:01:54

Ans. 1 day

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

   Like      Discuss      Correct / Improve     


 Q6. 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>
Log4j2017-03-01 16:03:03

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     


 Q7. 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>
Log4j2017-03-01 16:05:53

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     


 Q8. 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>
Log4j2017-03-01 16:07:26

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     


 Q9. What are some of the Log4j appenders ?Log4j2017-03-01 16:08:15

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     



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. Can you organize following Log4j levels in hierarchy ?

WARN, DEBUG,INFO, ERROR
Log4j2017-03-01 16:15:52

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


 Q11. What are the application Logging levels specified in your applications ? Log4j2017-03-01 16:17:21

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     


 Q12. What should be the logging level while logging exceptions ?Log4j2017-03-01 16:20:22

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     


 Q13. What is the difference between INFO and DEBUG logging levels ?Log4j2017-03-01 16:22:51

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     


 Q14. What is the difference between INFO and DEBUG logging levels ?Log4j2017-03-01 16:22:55

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


 Q15. What is the difference between DEBUG and TRACE logging levels ?Log4j2017-03-01 16:23:50

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


 Q16. How to change the backup log directory using log4j ?Log4j2017-03-03 09:40:37

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


 Q17. What does the property maxBackupIndex in Log4j means ?Log4j2017-03-03 09:46:51

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


 Q18. What is the difference between log4j and java logging api ?Log4j2017-03-03 14:15:09

 This question was recently asked at 'Credit Suisse'.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          Credit Suisse


 Q19. How will you design a Log4j kind of framework.Log4j2017-03-03 14:17:40

 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          Software AG



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. Difference between log4j and slf4j ?Logging2017-03-03 14:18:37

 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     Y Media Labs




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: