We use log4j2 and have two appenders: The Console
-Appender and a JDBC
-Appender.
The Console
-Appender does correctly log full stack traces of exceptions; however, the JDBC
-Appender does only log the exception itself, without stack trace. According our config, it should also write full trace: pattern="%throwable{50}
Here is our log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test" status="trace">
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" ignoreExceptions="false" >
<PatternLayout pattern="%d{ISO8601} %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<JDBC name="DatabaseAppender" tableName="logentry" ignoreExceptions="false" >
<ConnectionFactory class="....LoggingConnectionFactory" method="getDatabaseConnection" />
<Column name="eventDate" isEventTimestamp="true" />
<Column name="level" pattern="%level" isUnicode="false"/>
<Column name="logger" pattern="%logger" isUnicode="false"/>
<Column name="message" pattern="%message" isUnicode="false"/>
<Column name="exception" pattern="%throwable{50}" isUnicode="false"/>
</JDBC>
</Appenders>
<Loggers>
<Root level="${env:LOG_LEVEL}">
<AppenderRef ref="DatabaseAppender"/>
<AppenderRef ref="ConsoleAppender"/>
</Root>
</Loggers>
</Configuration>
What is wrong?
There are some similar posts here; but they target log4j1 or not JDBC Appender. Any help is highly appreciated! Thanks in advance!
- badera