3

I'm trying to use log4j on my selenium testing and I use maven to import log4j in my project. By going to mvnrepository.com I searched for apache log4j and added the Apache log4j 1.2.17 in my project but there was around 50 artifact missing errors displayed. I checked back to mvnrepository, It has a note that the log4j 1.2.17 was moved to New Group: org.apache.logging.log4j and New Artifact: log4j-core.

I added the Log4j-core 2.3 dependency on my maven project but the BasicConfigurator class cannot be resolved. I search for the class list of Log4j-core 2.3 and found out that the BasicConfigurator class is not part of the package. Only the Log4j 1.2.17 has this class.

How can I successfully import the BasicConfigurator class in my maven project? What Dependency do I need?

Thanks!

zlloyd
  • 111
  • 4
  • 14

1 Answers1

0

This will work in log4j2- ConfigurationSource configSource = new ConfigurationSource(logConfigurationStream); Configurator.initialize(null, configSource);

or you can make a use of Logger context by setting the configlocation in the following way- LoggerContext context = (LoggerContext)LogManager.getContext(false); context.setConfigLocation(new File(//log4j2.xmlPath).toURI());

deeksha gupta
  • 151
  • 1
  • 6