Bug 62788 - Add explicit ".encoding=UTF-8" to FileHandler configurations in logging.properties
Summary: Add explicit ".encoding=UTF-8" to FileHandler configurations in logging.prope...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.12
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-01 22:24 UTC by Konstantin Kolinko
Modified: 2018-11-05 10:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2018-10-01 22:24:38 UTC
This is inspired by a StackOverflow question [1].

While most of Tomcat 8.5/9.0 uses UTF-8 by default, the default configuration of (Async)FileHandlers in logging.properties is to use the system default character set.

1. There is no configuration for the "encoding" property of those FileHandlers in the default 'logging.properties' file.

2. The default value for that property is to use the system default character set. As documented in javadoc [2].


I find this odd.

My proposal is to add explicit configuration for the 'encoding' property of AsyncFileHandlers in Tomcat 9.0.x onwards to be 'UTF-8':

1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

etc.


I think that for a ConsoleHandler [3] it is expected to use the system encoding. It is used for monitoring at development time, and should not be used on a production system.

I think that a file written by a FileHandler is expected to preserve all information written to it, and UTF-8 suits better for this purpose.


[1] https://stackoverflow.com/questions/52591511/how-to-set-character-encoding-to-servletcontext-logs-in-tomcat

[2] http://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/juli/FileHandler.html

[3] https://docs.oracle.com/javase/6/docs/api/java/util/logging/ConsoleHandler.html
Comment 1 Mark Thomas 2018-10-08 13:26:41 UTC
+1
Comment 2 Mark Thomas 2018-11-05 10:50:18 UTC
Fixed in:
- trunk for 9.0.14 onwards
- 8.5.x for 8.5.36 onwards
- 7.0.x for 7.0.92 onwards