We updated our codebase recently from log4j2 v2.0-rc1 to v2.1. We use a
SocketServer. Once we did upgraded, we are not seeing exception stack
traces on lines where we used to. For example:
try {
throw new RuntimeException("Do you now to log my stackTrace?
stringstringstringE");
} catch (Exception e) {
LOGGER.error("Do you now to log my stackTrace? a:{} b:{} c:{} Yes,
I do!", "3443","4444","55555",e);
}
Does not give the stack trace. Running locally with a test log4j2 config
just writing to a file will give the stack trace.
Any ideas what changed?
We do use slf4j v.1.7.10 but that doesn't seem to be a factor because it
works locally with a test log4j2 config and also with the old SocketServer
and log4j2 v2.0-rc1.
We use a SocketServer so we also had to upgrade to TcpSocketServer.
Perhaps something has changed?
We start our socket server like:
> /usr/bin/java
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
> -DgrepToken=org.apache.logging.log4j.core.net.server.TcpSocketServer
> -server -Xms64M -Xmx256M -XX:+UseG1GC -XX:MaxGCPauseMillis=200
> -XX:GCPauseIntervalMillis=400 -Djava.net.preferIPv4Stack=true -cp
> /opt/twc/ecp:/opt/twc/ecp/lib/*
> org.apache.logging.log4j.core.net.server.TcpSocketServer 6000
> /opt/twc/ecp/log4j2.server.xml
The socket server process uses log4j2 config:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Configuration name="log4j2.server.xml" status="info">
>
> <Appenders>
>
> <RollingFile name="File" fileName="/opt/twc/logs/ecp.log"
> filePattern="/opt/twc/logs/ecp.log.%d{yyyy-MM-dd}" append="true"
> bufferedIO="true" immediateFlush="true">
>
> <PatternLayout>
>
> <Pattern>%d{ISO8601} %-14mdc{application} %-5level [%t]
> %logger - %msg%n</Pattern>
>
> </PatternLayout>
>
> <Policies>
>
> <TimeBasedTriggeringPolicy/>
>
> </Policies>
>
> </RollingFile>
>
> </Appenders>
>
> <Loggers>
>
> <Root level="all" includeLocation="true">
>
> <AppenderRef ref="File"/>
>
> </Root>
>
> </Loggers>
>
> </Configuration>
>
The local process uses log4j2 config:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Configuration status="info" name="log4j2.xml" monitorInterval="60">
>
> <Appenders>
>
> <Socket name="socket" host="ent06.lab.mystrotv.com" port="6000"
>> protocol="TCP" reconnectionDelay="1000" includeLocation="true">
>
> <SerializedLayout/>
>
> </Socket>
>
> </Appenders>
>
>
>> <Loggers>
>
> <Logger name="com.google" level="error" includeLocation="true"/>
>
> <Logger name="org.mybatis" level="error" includeLocation="true"/>
>
> <Logger name="org.apache.ibatis" level="error"
>> includeLocation="true"/>
>
> <Logger name="com.ryantenney" level="error" includeLocation="true"/>
>
> <Logger name="org.apache.http" level="error"
>> includeLocation="true"/>
>
> <Logger name="org.apache.activemq" level="error"
>> includeLocation="true"/>
>
> <Logger name="org.eclipse.jetty" level="error"
>> includeLocation="true"/>
>
> <Logger name="org.apache.cxf" level="error" includeLocation="true"/>
>
>
>> <Logger name="org.springframework" level="info"
>> includeLocation="true"/>
>
> <Logger
>> name="com.twc.ctg.ecp.service.history.HouseholdHistorySummaryQueue"
>> level="warn" includeLocation="true"/>
>
> <Logger
>> name="com.twc.ctg.ecp.persistence.mappers.HouseholdHistorySummaryMapper"
>> level="warn" includeLocation="true"/>
>
>
>> <Root level="info" includeLocation="true">
>
> <AppenderRef ref="socket"/>
>
> </Root>
>
> </Loggers>
>
> </Configuration>
>
>
Any ideas?