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);
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.
Implemented in 7.0 with r11145200 and will be in 7.0.19.
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.
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
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()".
Fixed in 6.0 with r1149099 and will be in 6.0.33. I won't backport these changes to 5.5.