Bug 32074

Summary: Layout.setContentType() needed!
Product: Log4j - Now in Jira Reporter: Bin Sun <sun2bin>
Component: LayoutAssignee: log4j-dev <log4j-dev>
Status: RESOLVED WORKSFORME    
Severity: blocker    
Priority: P3    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Bin Sun 2004-11-05 02:40:11 UTC
For Chinese developers, the log4j output often turns into chaos characters for 
Chinese text, eg. in email notifications.

After inspection, I found the problem is that "Layout.getContentType()" 
returns "text/plain" by default but there's no standard way to change it.

We need it to be "text/plain; charset=GBK", but we could only write our own 
Layout classes for each of the existing Layout sub-classes.

So Layout.setContentType() is urgently expected...
Comment 1 Curt Arnold 2004-11-05 23:49:05 UTC
Character encoding and content text are different concepts and it would be wrong to try to combine 
them.  Character encoding is appropriately handled at the appender, not the layout.  Layout's are 
always dealing with UTF-16 characters, the appenders are responsible for converting that to a byte 
stream.

WriterAppender derived appenders have an Encoding attribute that allows you to specify the encoding 
to be used.  Perhaps in your use case, that was not appropriately set or the appender in use does not 
appropriately control or report the encoding.

getContentType() is overriden in application specific layouts such as HTMLLayout (which returns text/
html) and XMLLayout (which I was surprised doesn't return text/xml).





Comment 2 Yoav Shapira 2005-08-02 20:20:44 UTC
I agree with Curt's comments, so I'm closing this issue.  setEncoding methods
are available and (in my experience with non-en_us locales) correctly implemented.