Method getLogger() no longer a member of Logger in log4j2?

huahsin68 picture huahsin68 · Sep 22, 2014 · Viewed 34.7k times · Source

I have the log4j-api-2.0.0.jar and log4j-core-2.0.2.jar import into my build path. But somehow the following code were fail:

import org.apache.logging.log4j.core.Logger;

public class TheClass {

    private static Logger log = Logger.getLogger(TheClass.class);

...

And the error message shows that:

The method getLogger(Class<TheClass>) is undefined for the type Logger

I am just so curious is getLogger() no longer a valid method in Logger?

Answer

Sotirios Delimanolis picture Sotirios Delimanolis · Sep 22, 2014

You'll notice Logger no longer declares such a method.

log4j version 2 has made some drastic changes. Here's the change log. getLogger seems to have been moved to a LogManager class.

Here's how they suggest making the migration.