Hi Ceki,

We actually did a bit more investigation into that same possibility and found 
that if you have
a test class similar to the one below:

import java.io.File;
import java.io.FileWriter;



public class FileTest {
    public static void main(String args[]) throws Exception {
        
        File file1 = new File("test.file");
        FileWriter writer1 = new FileWriter(file1);
        for (int i = 0 ; i < 20 ; i++) {
            writer1.write("Step 1 \n");
        }
        writer1.flush();
        FileWriter writer2 = new FileWriter(file1);
        for (int i = 0 ; i < 10 ; i++) {
            writer2.write("Step 2 \n");
        }
        writer2.flush();
        writer2.close();
        for (int i = 0 ; i < 20 ; i++) {
            writer1.write("Step 3 \n");
        }
        writer1.flush();
        writer1.close();
    }
}
 
We see null characters in the log. Seems to suggest perhaps we either have 2 
threads writing to the file as you suggested,
or two logical files open on the same physical file. When the second file is 
open (writer2) the phisical file is filled with null characters up to current 
end of file1. Then writer2 starts writing from the beginnig (overwritting some 
of the nulls with new information) and writer1 continues to appending after 
what it belives is the end of the file.
This is quite odd especially considering that we use AsyncAppenders (which open 
the files). 


Regards,
Lesley

-----Original Message-----
From: Ceki Gulcu [mailto:c...@qos.ch] 
Sent: Thursday, 11 June 2009 12:23 AM
To: Log4J Users List
Subject: Re: log4j v1.2.14 compatible with Java 1.6?



I bet that more than two application instances are writing to the same log 
file.  If you have such a requirement, try logback which supports multiple JVMs 
writing to the same log file.

Lesley Tay wrote:
> Hi all,
> 
> Wondering if anyone has tried running log4j 1.2.14 using Java 1.6.0_11?
> Have you come across any weird issues?
> 
> By weird I mean null characters being printed out to the log at random times:
> 2009-06-02 08:55:13,475 server1 principal logging-text
> 2009-06-02 08:55:14,872 server1 principal logging-text 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@ 
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^...@^@^@
> ^@
> 
> This application is running under Weblogic 10.3 using Java 1.6.0_11.
> The log files are being written out to an NFS filesystem mounted onto the 
> servers that Weblogic runs on. Not sure if this makes a difference.
> 
> Our log4j.xml config for this particular log file looks like this:
> 
>     <appender name="LOGGING" 
> class="org.apache.log4j.DailyRollingFileAppender">
>         <param name="File" value="${name}-${env}-logfile__HOSTNAME_.log"/>
>         <param name="Append" value="true"/>
> 
>         <!-- Rollover at midnight each day -->
>         <param name="DatePattern" value="'.'yyyy-MM-dd"/>
> 
>         <layout class="org.apache.log4j.PatternLayout">
>             <param name="ConversionPattern" value="%d{ISO8601}\t%m%n" />
>         </layout>
>     </appender>
> 
>     <appender name="LOGGING_ASYNC" class="org.apache.log4j.AsyncAppender">
>         <appender-ref ref="LOGGING"/>
>     </appender>
> 
>     <logger name="usage.logger" additivity="false">
>               <level value="info" />
>         <appender-ref ref="LOGGING_ASYNC"/>
>     </logger>
> 
> I can't remember whether someone has posted about this problem before. Any 
> ideas?
> 
> 
> 
> 
> Thanks,
> Lesley Tay
> Macquarie Group Limited
> e:      lesley....@macquarie.com 
> 
> 
> 
> NOTICE
> This e-mail and any attachments are confidential and may contain copyright 
> material of Macquarie Group Limited or third parties. If you are not the 
> intended recipient of this email you should not read, print, re-transmit, 
> store or act in reliance on this e-mail or any attachments, and should 
> destroy all copies of them. Macquarie Group Limited does not guarantee the 
> integrity of any emails or any attached files. The views or opinions 
> expressed are the author's own and may not reflect the views or opinions of 
> Macquarie Group Limited.
> 
> 

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to