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

Syslog PatternParser always escapes backslash

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.11.2
    • None
    • None
    • Java 1.8

      Log4J 2.11.2

    Description

      The KeyValuePair in the SyslogAppender always escapes the backslash even if you don't use it as escape character. It is forced on the PatternParser.java:177 (last parameter). 

      Steps to reproduce:

      1. Configure the KeyValuePair to read the ThreadContext variable "eventName":

       

      <Syslog name="SyslogAudit" format="RFC5424" host="10.1.2.55" port="1468"
                 protocol="TCP" appName="test" includeMDC="false" mdcId="test"                      
                 facility="USER" enterpriseNumber="18060" newLine="true"  
                 messageId="Audit">
         <LoggerFields>
             <KeyValuePair key="evt" value="%X{eventName}"/> 
         </LoggerFields>
      </Syslog>
      
      1. Set a ThreadLocal with a String with a backslash (here it is escaped because I'm inside Java) and then send a message:
      ThreadContext.put("eventName", "Attribute with backslash: [\\]");
      log.debug("Hello world!");

       

      The message received is:

      06-13-2019 14:52:50 User.Debug 10.1.2.54 1 2019-06-13T14:52:51.298-03:00 MacBook-Pro.local test 62462 Audit [test@18060 evt="Attribute with backslash: [
      ]
      "]
      Hello World!

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            chupetoide Nicolás Rossi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: