Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3238

Log4j 1.2 bridge API doesn't write the messages to rsyslog in proper "PatternLayout" mentioned in log4j.properties file when SysLogAppender is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Blocker
    • Resolution: Unresolved
    • 2.16.0
    • None
    • None

    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
       
      

       

       

       

      Attachments

        1. log4j2.tar.gz
          1.97 MB
          Tukesh

        Activity

          People

            rgoers Ralph Goers
            TukeshK Tukesh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: