You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2010/01/13 18:00:26 UTC
svn commit: r898836 - in /tomcat/trunk:
java/org/apache/juli/FileHandler.java webapps/docs/logging.xml
Author: fhanik
Date: Wed Jan 13 17:00:26 2010
New Revision: 898836
URL: http://svn.apache.org/viewvc?rev=898836&view=rev
Log:
Following changes
1. Default bufferSize is 0 - rely on system behavior
2. bufferSize of <0 will automatically flush the writer on each write
3. autoFlush for printWriter is false, otherwise we are duplicating the effort
4. date is a volatile variable so that a write to the variable gets propagated properly
Modified:
tomcat/trunk/java/org/apache/juli/FileHandler.java
tomcat/trunk/webapps/docs/logging.xml
Modified: tomcat/trunk/java/org/apache/juli/FileHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/juli/FileHandler.java?rev=898836&r1=898835&r2=898836&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/juli/FileHandler.java (original)
+++ tomcat/trunk/java/org/apache/juli/FileHandler.java Wed Jan 13 17:00:26 2010
@@ -71,7 +71,7 @@
* The as-of date for the currently open log file, or a zero-length
* string if there is no open log file.
*/
- private String date = "";
+ private volatile String date = "";
/**
@@ -100,7 +100,7 @@
/**
* Log buffer size
*/
- private int bufferSize = 8192;
+ private int bufferSize = 0;
// --------------------------------------------------------- Public Methods
@@ -145,15 +145,9 @@
try {
PrintWriter writer = this.writer;
if (writer!=null) {
- if (bufferSize > 0) {
- writer.write(result);
- } else {
- synchronized (this) {
- // OutputStreamWriter performs buffering inside its StreamEncoder,
- // and so to run without a buffer we have to flush explicitly
- writer.write(result);
- writer.flush();
- }
+ writer.write(result);
+ if (bufferSize < 0) {
+ writer.flush();
}
} else {
reportError("FileHandler is closed or not yet initialized, unable to log ["+result+"]", null, ErrorManager.WRITE_FAILURE);
@@ -314,7 +308,7 @@
OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos;
writer = new PrintWriter(
(encoding != null) ? new OutputStreamWriter(os, encoding)
- : new OutputStreamWriter(os), true);
+ : new OutputStreamWriter(os), false);
writer.write(getFormatter().getHead(this));
} catch (Exception e) {
reportError(null, e, ErrorManager.OPEN_FAILURE);
Modified: tomcat/trunk/webapps/docs/logging.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/logging.xml?rev=898836&r1=898835&r2=898836&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/logging.xml (original)
+++ tomcat/trunk/webapps/docs/logging.xml Wed Jan 13 17:00:26 2010
@@ -128,9 +128,11 @@
boolean value.</li>
<li>The root logger can define its set of handlers using a
<code>.handlers</code> property.</li>
- <li>Logging is buffered using a default buffer size of 8192 bytes.
- To change buffersize, use the <code>bufferSize</code> property of a handler.
- The value of <code>0</code> disables buffering.</li>
+ <li>Logging is buffered using a default buffer size of 0 bytes.
+ To change bufferSize, use the <code>bufferSize</code> property of a handler.
+ The value of <code>0</code> uses system default buffering.
+ The value of <code><0</code> forces a writer flush upon each log write.
+ A value <code>>0</code> uses a BufferedOutputStream with the defined value.</li>
<li>System property replacement is performed for property values which
contain ${systemPropertyName}.</li>
</ul>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org