0

Due to the latest log4j fiasco, we need to reorganize few of our codes. Earlier it was running on log4j-1.2.17. Now while using log4j-2.16, we're getting error at first place:

static Logger log = Logger.getLogger(TestAuthor.class);

Method 'getLogger' not found.

LogManager.resetConfiguration();- not found. PropertyConfigurator.configure(props);-not found

Is there any other way to define this?

Cris_new
  • 55
  • 1
  • 10
  • 1
    Log4j v1 didn't have the vulnerable functionality at all: https://stackoverflow.com/q/70310980/3001761. – jonrsharpe Dec 15 '21 at 08:31
  • log4j 1.2.17 is not affected by the vulnerability. But even if it were, the library has documentation that will tell you what changed between versions 1.x and 2.x, and how to instantiate loggers in 2.x. They even have a migration guide in their web site that you probably will want to read. – JustAnotherDeveloper Dec 15 '21 at 08:33
  • 3
    You are migrating from Log4J version 1.x to 2.x check https://logging.apache.org/log4j/2.x/manual/migration.html – seenukarthi Dec 15 '21 at 08:33

1 Answers1

1

Log4j's API changed between 1.x and 2.x. In log4j 2.x, you should use LogManager.getLogger instead:

static Logger log = LogManager.getLogger(TestAuthor.class);
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Thanks. Same type of instantiation error i'm getting for below props also- LogManager.resetConfiguration(); PropertyConfigurator.configure(prop); – Cris_new Dec 15 '21 at 09:31