Bug 46252 - Tomcat access log doesn't support Unicode
Summary: Tomcat access log doesn't support Unicode
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.17
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-20 11:18 UTC by Adam
Modified: 2011-07-21 10:26 UTC (History)
0 users



Attachments
2011-07-11_tc6_bug46252.patch (4.68 KB, patch)
2011-07-11 16:01 UTC, Konstantin Kolinko
Details | Diff
2011-07-11_tc6_bug46252_v2.patch (7.83 KB, patch)
2011-07-11 17:03 UTC, Konstantin Kolinko
Details | Diff
2011-07-11_tc6_bug46252_JMX.patch (1.59 KB, patch)
2011-07-11 18:17 UTC, Konstantin Kolinko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam 2008-11-20 11:18:55 UTC
AccessLogValve, which is responsible for handling the access log uses FileWriter (that doesn't support Unicode). I guess that instantiating the writer like this would solve the case:

writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(pathname), "UTF-8"), true);
Comment 1 Mark Thomas 2009-04-16 14:38:59 UTC
I am curious as to which elements you are trying to log that require UTF-8. Most will be ISO-8859-1. The only exceptions I can think of are user name and session attribute values.

I am concerned that whilst an access log is typically configured at the host level the user name encoding can vary from request to request (if you are using FORM) and session attributes are under no obligation to use a single consistent encoding. Therefore, it would be rather difficult to ensure the correct logging of each of these elements.

Given the above I am not in favour of using UTF-8 by default.

However, I can see the potential of making the encoding configurable with the default being the current behaviour. Therefore, I am marking this as an enhancement.

Patches are always very welcome and if you are interested in writing such a patch and need any assistance feel free to ask on the dev list.
Comment 2 Konstantin Kolinko 2011-07-11 15:16:40 UTC
Implemented in 7.0 with r11145200 and will be in 7.0.19.
Comment 3 Konstantin Kolinko 2011-07-11 16:01:05 UTC
Created attachment 27278 [details]
2011-07-11_tc6_bug46252.patch

Correction: that revision number above was r1145200

Here is patch that will be proposed for Tomcat 6.
Backport to Tomcat 5.5 is unlikely.
Comment 4 Konstantin Kolinko 2011-07-11 17:03:05 UTC
Created attachment 27279 [details]
2011-07-11_tc6_bug46252_v2.patch

Updated patch: added r1145237

This adds
in AccessLogValve:
- i18n for messages
- Log a failure if access log file cannot be opened.
- Autocreate directory if it is specified as a part of the file name
in FileHandler:
- Autocreate directory if it is specified as a part of the file name
Comment 5 Konstantin Kolinko 2011-07-11 18:17:32 UTC
Created attachment 27280 [details]
2011-07-11_tc6_bug46252_JMX.patch

Additional patch:
Expose the new "encoding" option through JMX.
I also fixed wrong mapping for "getEnabled()".
Comment 6 Konstantin Kolinko 2011-07-21 10:26:33 UTC
Fixed in 6.0 with r1149099 and will be in 6.0.33.
I won't backport these changes to 5.5.