Question

I'm fairly new to log4j. Trying to use log4j2.xml to configure. I added the file to the build path and it worked once, but is no longer working.

This is my log4j2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </appenders>
    <loggers>
        <root level="TRACE">
            <appender-ref ref="Console"/>
        </root>
    </loggers>
</configuration>

I stripped it down, just to test it to get it working. I checked debug, and the logger config is using Default.

I also tried naming the file log4j2-test.xml.

Any ideas?

Thanks

Was it helpful?

Solution

Since you uses "servlets" as the tag, I assume you are working in a web application. You need to place your log4j.xml into a location that your web application classloader can find. For example, the WEB-INF/classes directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top