Author: kkolinko
Date: Fri Jul 17 01:13:02 2009
New Revision: 794933

URL: http://svn.apache.org/viewvc?rev=794933&view=rev
Log:
Allow log file encoding to be configured for JULI FileHandler

Modified:
    tomcat/connectors/trunk/juli/src/java/org/apache/juli/FileHandler.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml
    tomcat/current/tc5.5.x/STATUS.txt

Modified: tomcat/connectors/trunk/juli/src/java/org/apache/juli/FileHandler.java
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/juli/src/java/org/apache/juli/FileHandler.java?rev=794933&r1=794932&r2=794933&view=diff
==============================================================================
--- tomcat/connectors/trunk/juli/src/java/org/apache/juli/FileHandler.java 
(original)
+++ tomcat/connectors/trunk/juli/src/java/org/apache/juli/FileHandler.java Fri 
Jul 17 01:13:02 2009
@@ -18,9 +18,13 @@
 
 package org.apache.juli;
 
+import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.sql.Timestamp;
 import java.util.logging.ErrorManager;
 import java.util.logging.Filter;
@@ -201,6 +205,16 @@
         if (suffix == null)
             suffix = getProperty(className + ".suffix", ".log");
 
+        // Get encoding for the logging file
+        String encoding = getProperty(className + ".encoding", null);
+        if (encoding != null && encoding.length() > 0) {
+            try {
+                setEncoding(encoding);
+            } catch (UnsupportedEncodingException ex) {
+                // Ignore
+            }
+        }
+
         // Get logging level for the handler
         setLevel(Level.parse(getProperty(className + ".level", "" + 
Level.ALL)));
 
@@ -256,7 +270,12 @@
         try {
             String pathname = dir.getAbsolutePath() + File.separator +
                 prefix + date + suffix;
-            writer = new PrintWriter(new FileWriter(pathname, true), true);
+            String encoding = getEncoding();
+            OutputStream os = new BufferedOutputStream(new FileOutputStream(
+                    pathname, true));
+            writer = new PrintWriter(
+                    (encoding != null) ? new OutputStreamWriter(os, encoding)
+                            : new OutputStreamWriter(os), true);
             writer.write(getFormatter().getHead(this));
         } catch (Exception e) {
             reportError(null, e, ErrorManager.OPEN_FAILURE);

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=794933&r1=794932&r2=794933&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Fri Jul 17 01:13:02 2009
@@ -213,6 +213,9 @@
       <fix>
         <bug>38483</bug>: Thread safety issues in AccessLogValve classes. 
(kkolinko)
       </fix>
+      <add>
+        Allow log file encoding to be configured for JULI FileHandler. 
(kkolinko)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Jasper">

Modified: tomcat/current/tc5.5.x/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/current/tc5.5.x/STATUS.txt?rev=794933&r1=794932&r2=794933&view=diff
==============================================================================
--- tomcat/current/tc5.5.x/STATUS.txt (original)
+++ tomcat/current/tc5.5.x/STATUS.txt Fri Jul 17 01:13:02 2009
@@ -90,11 +90,6 @@
   +1: markt, kkolinko, rjung
   -1: 
 
-* Allow encoding to be specified for JULI FileHandler
-  http://svn.apache.org/viewvc?rev=793882&view=rev
-  +1: kkolinko, markt, rjung
-  -1:
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=40380
   Correct synchronisation of expire(). Method should only run once.
   http://svn.apache.org/viewvc?rev=793981&view=rev



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to