Log4j2 - configuring

Ibolit picture Ibolit · Nov 18, 2012 · Viewed 42.1k times · Source

I am trying to adopt Log4j2 in my new project, but I get my logs in catalina.out, and the first one is always: ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger. It seems that I have done everything according to Log4j2 docs, but still.

Here is what I have actually done:

  1. added log4j-api-2.0-beta3.jar to my project
  2. created a log4j2.xml file and put it in a location that is on the classpath (currently, in /usr/local/tomcat/home/lib. In fact, I took a sample file from Log4J2 web-page.
  3. restarted tomcat.

I am using Tomcat 7, MacOS X 10.8, Java 7.

What am I missing?

Just in case, here is the log4j2.xml I am using:

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="warn" name="MyApp" packages="">
  <appenders>
    <File name="MyFile" fileName="logs/app.log">
      <PatternLayout>
        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
      </PatternLayout>
    </File>
  </appenders>
  <loggers>
    <root level="trace">
      <appender-ref ref="MyFile"/>
    </root>
  </loggers>
</configuration>

Answer

Markus Wilke picture Markus Wilke · Nov 18, 2012

I had the same problem. After adding also log4j-core-2.0-beta3.jar to the classpath it worked.