YU Chang created LOG4J2-1969:
--------------------------------
Summary: TcpSocketServer does not replace any “{}” in message
Key: LOG4J2-1969
URL: https://issues.apache.org/jira/browse/LOG4J2-1969
Project: Log4j 2
Issue Type: Bug
Components: Appenders
Affects Versions: 2.7, 2.6.2
Environment: Spring boot 1.5.4
java 8
Reporter: YU Chang
I have a spring boot(v1.5.4) web application which use log4j-2.7 for logging.
It works well when write log message to file or console, but when send message
to `TcpSocketServer`, the log server just output the message without the "{}"
formatting. for example, for this code:
{code:java}
logger.info("Request from [{}] to [{}]", ipInfo, reqPath);
{code}
The `RollingfileAppender` and `ConsoleAppender` will output:
INFO 2017-07-06 16:46:07,929 [127.0.0.1][/senten/align] AuthFilter
(http-nio-8180-exec-2) Request from [127.0.0.1] to [/senten/align]
But the `SocketAppender` just ouput:
INFO 2017-07-06 16:46:07,929 [127.0.0.1][/senten/align] AuthFilter
(http-nio-8180-exec-2) Request from [{}] to [{}]
This is my config with `SocketAppenders` in log4j.xml
<Appenders>
<Socket name="socket" host="127.0.0.1" port="9898">
<SerializedLayout />
</Socket>
........
</Appenders>
This is my config file `log4j2-socket.xml` for `TcpSocketServer`:
<Configuration status="WARN">
<Appenders>
<RollingFile name="default" fileName="Logs/app.log"
filePattern="Logs/${date:yyyy-MM}/app-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout>
<Pattern>%-5p %d [%X{ip}][%X{reqPath}] %c{1}
(%t) %m %ex%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval = "30"
modulate="true"/>
<SizeBasedTriggeringPolicy size="200 MB" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="default" level="DEBUG" />
</Root>
</Loggers>
</Configuration>
And, I use this command for start `TcpSocketServer`:
java -classpath log4j-core-2.7.jar:log4j-api-2.7.jar:jcommander-1.48.jar
org.apache.logging.log4j.core.net.server.TcpSocketServer -p 9898 -c
log4j2-socket.xml
Does anybody know what's going wrong here, and how to fix it? Thanks!
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)