Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Log and Logger?

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.

like image 759
user926958 Avatar asked Dec 14 '12 01:12

user926958


1 Answers

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.

like image 146
Kevin Bowersox Avatar answered Sep 28 '22 04:09

Kevin Bowersox