Monday, July 22, 2019

Log4j Logger

 Q- What is the log level in production environment?

Answer:- Error

Q- Is logger thread safe?

Yes.

Q- What are different logging level in Java?

  • DEBUG
  • INFO
  • WARN
  • ERROR
  • TRACE
  • FATAL
  • OFF

Q- How logging in Java affects performance?

Uses either WARN ERROR or FINER, FINEST java logging level in production environment. Never use DEBUG level logging in java in production.

Q- Different types of Appenders in Log4j?

  • ConsoleAppender
  • FileAppender
  • RollingFileAppender, DailyRollingFileAppender
  • JDBCAppender
  • SMTPAppender
  • SocketAppender
  • SyslogAppender
  • TelnetAppender
  • WriterAppender
  • AsyncAppender
  • JMSAppender
  • AppenderSkeleton
  • LF5Appender
  • NTEventLogAppender
  • NullAppender
  • SocketHubAppender
  • ExternallyRolledFileAppender

Q- Explain layouts in log4j?

Q- How does log Levels work in Log4J?

A log request of level n in a logger with level m is enabled if m >= n.

For the standard levels, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.

Q- Explain few format characters used in log4j.

Q- How can you log into the database using Log4j?

Q- Explain immediateFlush property of FileAppender.

Q- What is difference between slf4j and log4j?

Log4j:- Log4j is a logging framework which is written in java. It is an open-source logging API for java.under the Apache Software License.

SLF4J(Simple Logging Façade for java)

  • SLF4J is not a logging implementation.
  • SLF4J and Log4J focus on different areas and they are not similar components.
  • SLF4J is basically an abstraction layer - it is an abstraction for all those logging frameworks in Java similar to log4J
  • SLF4J is an API designed to give generic access to many logging frameworks;

Therefore, you cannot compare both Log4j & SLF4J.

No comments:

Post a Comment