Prev Next

Java / log4j

1. Difference between apache commons logging and log4j.

Apache commons logging is a facade API that abstracts the underlying implementation. Using commons logging, one can decide between different implementations such as log4j, slf4j and java util Logging without touching the code....

Read full answer

2. Can log4j logging be stored to database?

Yes. The logging can be written to a database, file, console, JMS and Apache flume.

Read full answer

3. What is log4j?

log4j framework is a reliable, fast and light weigtht logging API. It is written using Java and distributed under Apache software license....

Read full answer

4. Components of log4j framework.

There are mainly 3 components. Logger captures logging information.

Read full answer

5. Advantages of using log4j framework.

Thread safe. Optimized for performance....

Read full answer

6. What are the different log levels in Log4j?

There are 8 levels. You can also define your custom levels by sub-classing the Level class.

Read full answer

7. What is Appender in Log4j?

Appender is used to deliver LogEvents to its destination. For example, it is used to write the logs in the file.

Read full answer

8. Explain different logging levels in log4j.

The DEBUG level designates fine-grained informational events useful to debug an application. The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.

Read full answer

9. Explain few format characters used in log4j.

The format characters used in log4j are, L - it is used to output the line number from where the logging request was processed or issued. m - It is used to output the application supplied message related to the...

Read full answer

10. Is log4j thread safe?

Yes, Log4j is a thread-safe; its components are built to be used in multithreaded systems.

Read full answer

11. How can you log into the database using Log4j?

The log4j API provides the object org.apache.log4j.jdbc. JDBCAppender object that can put logging information in a database.

Read full answer

12. Different types of Appenders in Log4j.

There are many types of appenders that include, ConsoleAppender logs to standard output, FileAppender writes logs to some file, Rolling file appender appends to a file with a maximum size.

Read full answer

13. Explain layouts in log4j.

An appender uses Layout to format the log before writing to the destination. The layout allows formatting logging information in various patterns and styles.

Read full answer

14. 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.

Read full answer

15. Explain immediateFlush property of FileAppender.

ImmediateFlush property enables the output stream to the file being flushed with each append operation. By default the property is set to true ....

Read full answer

16. Why should we prefer log4j framework while Java provides logging API?

Log4j has following advantages over standard logging API: robust logging. log4j has more features available than standard logging API.

Read full answer

17. What is SLF4J?

The Simple Logging Facade for Java (SLF4J) is a simple facade or abstraction for various logging frameworks such as java.util.logging, LogBack, log4j allowing the end user to plug in the desired logging framework at deployment time. It is not itself...

Read full answer

18. Mention larger logging domains for your applications.

Diagnostic logging are used to understand the state of the system at a particular point of interest. Security logging establishes accountability and useful for forensics.

Read full answer

19. What is MDC object in slf4j?

MDC stands for Mapped Diagnostic Context , a feature within the SLF4J (Simple Logging Facade for Java) API that allows developers to enrich log messages with contextual information. It is particularly useful in multi-threaded applications and distributed systems for tracing...

Read full answer

«
»

Comments & Discussions