I am using log4j2 with this 2 dependencies:
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-1.2-api</artifactId>
        <version>2.6.2</version>
    </dependency>
When I try to log for example an error with a throwable like:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.Test;
public class Test {
private static final Logger logger = LogManager.getLogger(Test.class);
@Test
public void testSendMessage() throws Exception {
    Exception exception = new Exception("some exception");
    logger.error("error with exception", exception);
}
}
using patternlayout:
<Configuration>
<properties>
    <property name="filters">org.testng,org.apache.maven,sun.reflect,java.lang.reflect</property>
</properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" direct="true">
            <PatternLayout pattern="%maxLen{%d{DEFAULT} [%p]  %c{-3}:%L - %enc{%m} %xEx{filters(${filters})}%n}{200}"/>
        </Console>
</Appenders>
<Loggers>
    <logger name="my.test.class.path" level="trace" additivity="false">
        <AppenderRef ref="ConsoleAppender" />
    </logger>
</Loggers>
</Configuration>
Then the filtered packages won't disappear from the stacktrace, I can't even manipulate the stacktrace in any way like maximizing the lines:
%xEx{5}
Highlightning also don't work in eclipse nor in Kibana(ELK environment).
Can anybody help?
Could it be that the %xEx PatternLayout converter doesn't support property substitution in its options?
What if you put the packages you want to filter directly in the filters list?
It may be worth raising a Jira ticket on the Log4j 2 issue tracker for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With