Details
-
Bug
-
Status: Reopened
-
Blocker
-
Resolution: Unresolved
-
2.16.0
-
None
-
None
-
JDK .1.8 :-
copy-jdk-configs-3.3-10.el7_5.noarch
java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.i686
java-1.8.0-openjdk-devel-1.8.0.242.b08-0.el7_7.i686
java-1.8.0-openjdk-headless-1.8.0.242.b08-0.el7_7.i686JVM arguments :-
-Dlog4j1.compatibility=true
Jar used :-
log4j-1.2-api-2.16.0.jar
log4j-api-2.16.0.jar
log4j-core-2.16.0.jar
JDK .1.8 :- copy-jdk-configs-3.3-10.el7_5.noarch java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.i686 java-1.8.0-openjdk-devel-1.8.0.242.b08-0.el7_7.i686 java-1.8.0-openjdk-headless-1.8.0.242.b08-0.el7_7.i686 JVM arguments :- -Dlog4j1.compatibility=true Jar used :- log4j-1.2-api-2.16.0.jar log4j-api-2.16.0.jar log4j-core-2.16.0.jar
Description
Log4j 1.2 bridge API doesn't write the messages to rsyslog in proper "PatternLayout" mentioned in log4j.properties file when SysLogAppender is used .
You can see log messages are missing Conversion Patterns effect like string "MyMain" , Data, ClassName etc.
log4j.properties file :-
log4j.rootLogger=DEBUG,SYSLOG
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.Threshold=DEBUG
log4j.appender.SYSLOG.syslogHost=localhost
log4j.appender.SYSLOG.port=514
log4j.appender.SYSLOG.header=true
log4j.appender.SYSLOG.Facility=LOCAL3
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.conversionPattern=MyMain[%pid] :%t: %c %-4p %m%n
Source code ( LoggerExample.java ) :-
package test.logger; import org.apache.log4j.Logger; import java.io.*; import java.sql.SQLException; import java.util.concurrent.TimeUnit; public class LoggerExample{ static Logger log = Logger.getLogger(LoggerExample.class.getName()); public static void main(String[] args)throws IOException,SQLException{ log.debug("log4j-shell Starting..."); while(true){ System.out.println("I'm running..."); log.debug("Test Log4j-shell this is a debug message"); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } } }
Sample message created :-
log4j-shell Starting... Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message Test Log4j-shell this is a debug message