Bug 56915

Summary: PatternLayout - %c in ConversionPattern is not returning what is expected.
Product: Log4j - Now in Jira Reporter: kumi.hagimoto
Component: LayoutAssignee: log4j-dev <log4j-dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.2.17   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description kumi.hagimoto 2014-09-04 22:59:27 UTC
Using this pattern:
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

==> result 

2014-09-04 15:42:51 DEBUG headers:116 - http-outgoing-1 << Connection: Keep-Alive
2014-09-04 15:42:51 DEBUG headers:116 - http-outgoing-1 << Content-Type: application/json; charset=utf-8


Just for comparison, I ran the same code with the following pattern (replacing %c{1} with %C:
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%L - %m%n" />

==> result

2014-09-04 15:45:12 DEBUG org.apache.http.impl.conn.LoggingManagedHttpClientConnection:116 - http-outgoing-2 << Connection: Keep-Alive
2014-09-04 15:45:12 DEBUG org.apache.http.impl.conn.LoggingManagedHttpClientConnection:116 - http-outgoing-2 << Content-Type: application/json; charset=utf-8

"%c{1}" is not getting the right-most component as described in the documentation.

Please let me know if you need more info, or I'm doing something wrong!
Thanks,
Kumi