in Discussion & reviews - 22 Jan, 2011
Why to use log4j instead of java classical logging
log4j makes your logging not only easier but efficient too. You are supposed to write less code. And can set its parameter at run time without changing actual code.
Read the below features which can make you use log4j.
- log4j is thread-safe.
- log4j is optimized for speed.
- log4j is based on a named logger hierarchy.
- log4j supports multiple output appenders per logger.
- log4j supports internationalization.
- log4j is not restricted to a predefined set of facilities.
- Logging behavior can be set at run time using a configuration file.
- log4j is designed to handle Java Exceptions from the start.
- log4j uses multiple levels, namely ALL, TRACE, DEBUG, INFO, WARN, ERROR and FATAL.
- The format of the log output can be easily changed by extending the Layout class.
- The target of the log output as well as the writing strategy can be altered by implementations of the Appender interface.
- log4j is fail-stop. However, although it certainly strives to make sure delivery, log4j does not guarantee that each log statement will be delivered to its destination.