For log4j2, is it possible for using different pattern layout for different log level and output to SYSTEM_OUT?
Here is my log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="debugMsg" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} %l - %msg%n"/>
</Console>
<Console name="infoMsg" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="trace" additivity="false">
<AppenderRef ref="infoMsg" level="info"/>
<AppenderRef ref="debugMsg" level="debug"/>
</Root>
</Loggers>
</Configuration>
However, the INFO level message are shown in both "infoMsg" and "debugMsg" pattern.
2015-12-24 10:51:56.176 Log4j is ready.
[INFO ] 2015-12-24 10:51:56.176 com.myftpserver.MyFtpServer.<init>(MyFtpServer.java:65) - Log4j is ready.
2015-12-24 10:51:56.176 Configuration file is loaded
[INFO ] 2015-12-24 10:51:56.176 com.myftpserver.Configuration.load(Configuration.java:74) - Configuration file is loaded
[DEBUG] 2015-12-24 10:51:56.176 com.myftpserver.Configuration.load(Configuration.java:82) - supportPassiveMode=true
2015-12-24 10:51:56.301 User Manager class is loaded.
[INFO ] 2015-12-24 10:51:56.301 com.myftpserver.Configuration.load(Configuration.java:119) - User Manager class is loaded.
2015-12-24 10:51:56.301 File Manager class is loaded.
[INFO ] 2015-12-24 10:51:56.301 com.myftpserver.Configuration.load(Configuration.java:121) - File Manager class is loaded.
2015-12-24 10:51:56.301 Server Initialization completed.
[INFO ] 2015-12-24 10:51:56.301 com.myftpserver.MyFtpServer.<init>(MyFtpServer.java:69) - Server Initialization completed.
2015-12-24 10:51:56.301 Available passive port:[1232, 1233, 1234]
[INFO ] 2015-12-24 10:51:56.301 com.myftpserver.MyFtpServer.<init>(MyFtpServer.java:75) - Available passive port:[1232, 1233, 1234]
So, is it possible to remove duplicate item?
thank you very much and Merry X'mas