[ 
https://issues.apache.org/jira/browse/LOG4J2-2630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nicolás Rossi updated LOG4J2-2630:
----------------------------------
    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:
 # Configure the KeyValuePair to read the ThreadContext variable "eventName":

 
{code:java}
<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>
{code}
 # Set a ThreadLocal with a String with a backslash (here it is escaped because 
I'm inside Java) and then send a message:

{code:java}
ThreadContext.put("eventName", "Attribute with backslash: [\\]");
log.debug("Hello world!");{code}
 

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="{color:#ff0000}Attribute 
with backslash: [\\]{color}"] Hello World!

 

  was:
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:
 # Configure the KeyValuePair to read the ThreadContext variable "eventName":

 
{code:java}
<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>
{code}
 # Set a ThreadLocal with a String with a backslash (here it is escaped because 
I'm inside Java) and then send a message:

{code:java}
ThreadContext.put("eventName", "Attribute with backslash: [\\]");
log.debug("Hello world!");{code}
 

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="{color:#FF0000}Attribute 
with backslash: [\\]{color}"] Hello World!

 


> Syslog PatternParser always escapes backslash
> ---------------------------------------------
>
>                 Key: LOG4J2-2630
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2630
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, Pattern Converters
>    Affects Versions: 2.11.2
>         Environment: Java 1.8
> Log4J 2.11.2
>            Reporter: Nicolás Rossi
>            Priority: Minor
>
> 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:
>  # Configure the KeyValuePair to read the ThreadContext variable "eventName":
>  
> {code:java}
> <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>
> {code}
>  # Set a ThreadLocal with a String with a backslash (here it is escaped 
> because I'm inside Java) and then send a message:
> {code:java}
> ThreadContext.put("eventName", "Attribute with backslash: [\\]");
> log.debug("Hello world!");{code}
>  
> 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="{color:#ff0000}Attribute 
> with backslash: [\\]{color}"] Hello World!
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to