Skip to content

Instantly share code, notes, and snippets.

@amorton
Created Aug 18, 2011
Embed
What would you like to do?
log4j 1.2.16 diff to show FileAppender been reset.
diff --git a/build.xml b/build.xml
index e5ec33b..c05f24c 100644
--- a/build.xml
+++ b/build.xml
@@ -99,8 +99,8 @@
<!-- Directory for temporary files. -->
<property name="dist.tmp" value="${dist.dir}/tmp"/>
- <property name="javac.source" value="1.2"/>
- <property name="javac.target" value="1.1"/>
+ <property name="javac.source" value="1.5"/>
+ <property name="javac.target" value="1.5"/>
<!-- destination for generated documentation on Apache web host -->
<property name="apache.javadoc_dest" value="/www/logging.apache.org/log4j/docs"/>
diff --git a/src/main/java/org/apache/log4j/FileAppender.java b/src/main/java/org/apache/log4j/FileAppender.java
index 0728695..de142aa 100644
--- a/src/main/java/org/apache/log4j/FileAppender.java
+++ b/src/main/java/org/apache/log4j/FileAppender.java
@@ -278,7 +278,7 @@ public class FileAppender extends WriterAppender {
synchronized
void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize)
throws IOException {
- LogLog.debug("setFile called: "+fileName+", "+append);
+ LogLog.debug("setFile called for [" + name +"]: "+fileName+", "+append);
// It does not make sense to have immediate flush and bufferedIO.
if(bufferedIO) {
@@ -320,7 +320,7 @@ public class FileAppender extends WriterAppender {
this.bufferedIO = bufferedIO;
this.bufferSize = bufferSize;
writeHeader();
- LogLog.debug("setFile ended");
+ LogLog.debug("setFile ended for [" + name +"]: qw = [" + ((qw == null) ? "NULL" : qw.toString()) + "]");
}
@@ -331,6 +331,7 @@ public class FileAppender extends WriterAppender {
*/
protected
void setQWForFiles(Writer writer) {
+ LogLog.debug("setQWForFiles called for [" + name + "]");
this.qw = new QuietWriter(writer, errorHandler);
}
diff --git a/src/main/java/org/apache/log4j/WriterAppender.java b/src/main/java/org/apache/log4j/WriterAppender.java
index 981c02d..d67873d 100644
--- a/src/main/java/org/apache/log4j/WriterAppender.java
+++ b/src/main/java/org/apache/log4j/WriterAppender.java
@@ -345,6 +345,11 @@ public class WriterAppender extends AppenderSkeleton {
void reset() {
closeWriter();
this.qw = null;
+ LogLog.debug("Reset called for appender ["+name+"].");
+ StringBuilder sb = new StringBuilder();
+ for (StackTraceElement ste : Thread.currentThread().getStackTrace())
+ sb.append(ste.toString() + "\n");
+ LogLog.debug(sb.toString());
//this.tp = null;
}
@amorton
Copy link
Author

amorton commented Aug 18, 2011

Used to build a custom log4j 1.2.16 to use with Brisk. Logs to std out to show when a WriterAppender is reset and what was in the call stack.

@amorton
Copy link
Author

amorton commented Aug 18, 2011

Requires log4j.debug=true to be passed to the mapred task, make sure this is in the mapred-site.xml file

<property>
  <name>mapred.child.java.opts</name>
  <value>-Xmx256m -Dlog4j.debug=true</value>
  <description>
    Tune your mapred jvm arguments for best performance. 
    Also see documentation from jvm vendor.
  </description>
</property>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment