You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/11/07 00:04:51 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j FileAppender.java WriterAppender.java
ceki 01/11/06 15:04:51
Modified: docs HISTORY critique.html
src/java/org/apache/log4j FileAppender.java
WriterAppender.java
Log:
- Added support for different encodings in WriterAppender. Thanks to
Ben Sandee for submitting the relevant patch. [*]
Revision Changes Path
1.72 +3 -0 jakarta-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- HISTORY 2001/10/22 23:08:59 1.71
+++ HISTORY 2001/11/06 23:04:51 1.72
@@ -14,6 +14,9 @@
- Log4j is now configurable using JMX. [*]
+ - Added support for different encodings in WriterAppender. Thanks to
+ Ben Sandee for submitting the relevant patch. [*]
+
- Added the FINE level as an alias for the DEBUG level to make migration
from log4j to j.u.l. and vice versa easier. [*]
1.26 +3 -3 jakarta-log4j/docs/critique.html
Index: critique.html
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/critique.html,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- critique.html 2001/10/22 23:08:59 1.25
+++ critique.html 2001/11/06 23:04:51 1.26
@@ -550,14 +550,14 @@
<li><p><a href="pub-support/MichaelChermside.html">Michael Chermside</a>
<li><p><a href="pub-support/EdoardoComar.html">Edoardo Comar</a>
<li><p><a href="pub-support/LeonardReinhart.html">Leonard Reinhart </a>
+<li><p><a href="pub-support/JamesMaggs.html">James Maggs</a>
+<li><p><a href="pub-support/AlexRojkov.html">Alex Rojkov</a>
+<!--
-<!--
-<li><p><a href="pub-support/.html"></a>
-<li><p><a href="pub-support/.html"></a>
<li><p><a href="pub-support/.html"></a>
<li><p><a href="pub-support/.html"></a>
<li><p><a href="pub-support/.html"></a>
1.30 +2 -1 jakarta-log4j/src/java/org/apache/log4j/FileAppender.java
Index: FileAppender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/FileAppender.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- FileAppender.java 2001/08/14 21:11:52 1.29
+++ FileAppender.java 2001/11/06 23:04:51 1.30
@@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.Writer;
import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
@@ -271,7 +272,7 @@
}
reset();
- Writer fw = new FileWriter(fileName, append);
+ Writer fw = createWriter(new FileOutputStream(fileName, append));
if(bufferedIO) {
fw = new BufferedWriter(fw);
}
1.18 +45 -1 jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java
Index: WriterAppender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WriterAppender.java 2001/07/25 19:43:44 1.17
+++ WriterAppender.java 2001/11/06 23:04:51 1.18
@@ -47,6 +47,13 @@
protected boolean immediateFlush = true;
/**
+ The encoding to use when opening an InputStream. <p>The
+ <code>encoding</code> variable is set to <code>null</null> by
+ default which results in the utilization of the system's default
+ encoding. */
+ protected String encoding;
+
+ /**
This is the {@link QuietWriter quietWriter} where we will write
to.
*/
@@ -189,7 +196,6 @@
writeFooter();
reset();
}
-
/**
Close the underlying {@link java.io.Writer}.
*/
@@ -204,6 +210,44 @@
}
}
}
+
+ /**
+ Returns an OutputStreamWriter when passed an OutputStream. The
+ encoding used will depend on the value of the
+ <code>encoding</code> property. If the encoding value is
+ specified incorrectly the writer will be opened using the default
+ system encoding (an error message will be printed to the loglog. */
+ protected
+ OutputStreamWriter createWriter(OutputStream os) {
+ OutputStreamWriter retval = null;
+
+ String enc = getEncoding();
+ if(enc != null) {
+ try {
+ retval = new OutputStreamWriter(os, enc);
+ } catch(IOException e) {
+ LogLog.warn("Error initializing output writer.");
+ LogLog.warn("Unsupported encoding?");
+ }
+ }
+ if(retval == null) {
+ retval = new OutputStreamWriter(os);
+ }
+ return retval;
+ }
+
+ public
+ String getEncoding() {
+ return encoding;
+ }
+
+ public
+ void setEncoding(String value) {
+ encoding = value;
+ }
+
+
+
/**
Set the {@link ErrorHandler} for this FileAppender and also the
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>