Isn't the write method in PrudentWriter (see [1]) a copy-and-paste of code safeWrite() method in logback's FileAppender (see [2])?
[1] http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/helpers/PrudentWriter.java?revision=909868&view=markup&pathrev=909918 [2] http://github.com/ceki/logback/blob/master/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
On 13/02/2010 7:24 PM, [email protected] wrote:
Author: carnold Date: Sat Feb 13 18:24:46 2010 New Revision: 909868 URL: http://svn.apache.org/viewvc?rev=909868&view=rev Log: Bug 48704: Add purient mode to FileAppender Added: + + /** + * Write string to encapsulated writer within a lock + * on the associated FileChannel. Channel will be + * repositioned to the end of the file if necessary. + */ + public void write(final String str) throws IOException { + FileLock lock = null; + try { + lock = channel.lock(); + long size = channel.size(); + if (size != channel.position()) { + channel.position(size); + } + super.write(str); + super.flush(); + } finally { + if (lock != null) { + lock.release(); + } + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
