I have seen people use this way:
Logger logger = Logger.getLogger("com.foo");
and I have seen the other way:
Log log = LogFactory.getLog(CLASS.class);
What's the differences behind them? Thanks.
The call to Logger.getLogger is from the log4j api.
Logger logger = Logger.getLogger("com.foo");
Documentation
The call to LogFactory.getLog() is from the commons-logging api.
Log log = LogFactory.getLog(CLASS.class);
Documentation
log4j is a logging framework, i.e. it provides the code to log messages. Commons-logging is an abstraction layer for logging frameworks, it doesn't log anything itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With