We all know that using SLF4J to define logging is pretty much standard in the current situation.

If the following statement:

private static final Logger logger = LoggerFactory.getLogger(Dom4JParserUnitTest.class);
Copy the code

But sometimes, we do

Log log = LogFactory.getLog(CLASS.class);
Copy the code

This statement.

What is the difference between the two statements above?

answer

The main difference is the API used. LogFactory is the COMMONs-logging API.

This API hasn’t been updated in years.

There are probably a number of projects still in use, but use the SLF4J API whenever possible.

If you want to write:

private static final Logger log= LoggerFactory.getLogger(Dom4JParserUnitTest.class);
Copy the code

Is that ok?

Of course you can, but later you will only use log, which may be confused with the log defined in LogFactory.

So a lot of project logging, if using SLF4J, will usually use Logger.

www.ossez.com/t/log-logge…