In the log4j2 documentation log4j2 java configuration the default configuration is this:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<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="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
This will produce logging for levels ERROR or FATAL to the Console. My default logging works in the same way. The problem i run into is when I do this, though:
<logger name="com.foo.Bar" level="TRACE"/>
<Root level="ERROR">
<AppenderRef ref="STDOUT">
</Root>
According to the documentation, log4j2 java configuration, this will
eliminate all the TRACE output from everything except com.foo.Bar.
My implementation, on the other hand, works as though the
<logger name="com.foo.Bar" level="TRACE"/>
wasn't even there. It will still only print out error logs.
Questions
- Has anyone else encountered this problem?
- Can anyone reproduce it?
- Does anyone know how to fix it? I almost would give someone a dollar. I would definitely settle for marking their answer green, though.
Here is some information about my setup:
Maven Dependencies
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
Other
I am testing this in the appropriate class. I am running a JUnit test file. I've used a src/main .xml file and i've used a src/test .xml file. Both end up with the same results.
End Goal
My end goal is to have a specific logger send SMTP requests. I am pretty sure I know how to do this, i am just struggling with this small problem
LogManager
class? and which jar you have used here? – Derivation