logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CAGATAY TUNALI <cagatay.tun...@oksijen.com>
Subject Re: Dummy trouble
Date Wed, 09 Jun 2004 13:13:23 GMT
Hi,

I have a problem about rollover behaviour of log4j. Let me explain my 
problem step by step. 
I have an xml file which configures log4j for me. Here is the xml file
/**********************************************************************************************************/
<appender name="GatewayAppender" 
class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="Gateway.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="MaxBackupIndex" value="10"/>
        <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-4r %d [%t] %-5p %c [%x] - 
%m%n" />
        </layout>
</appender>
<logger name="GatewayLogger" additivity="false">
        <level value="DEBUG"/>
        <appender-ref ref="GatewayAppender"/>
</logger>
<root>
        <priority value="DEBUG" />
        <appender-ref ref="GatewayAppender" />
</root>
/**********************************************************************************************************/

I also manually change the settings of log4j (like debug level) from the 
program at runtime. My program produces 100-200 logs every second. 
Sometimes I want to close the log file that is used at present and open a 
new file before the file reaches maximum file size. I have a command 
"reset log"
which resets the log file and opens a new log file. This command executes 
these lines
/**********************************************************************************************************/
RollingFileAppender rfa = 
(RollingFileAppender)Logger.getRootLogger().getAppender("GatewayAppender");
rfa.rollOver();
/**********************************************************************************************************/

I also must mention that I use different threads for logging(15) and for 
commands.
In my program generally I take exception (not always) when I call "reset 
log" command. Exception is
/**********************************************************************************************************/
log4j:ERROR Write failure.
java.io.IOException: Stream closed
        at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:127)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:144)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:204)
        at java.io.Writer.write(Writer.java:126)
        at 
org.apache.log4j.helpers.CountingQuietWriter.write(CountingQuietWriter.java:36)
        at 
org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:292)
        at 
org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:225)
        at org.apache.log4j.WriterAppender.append(WriterAppender.java:150)
        at 
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
        at 
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:57)
        at org.apache.log4j.Category.callAppenders(Category.java:187)
        at org.apache.log4j.Category.forcedLog(Category.java:372)
        at org.apache.log4j.Category.debug(Category.java:241)
/**********************************************************************************************************/
After this log4j continue to log but not rollover the file. But when I 
call again it works perfectly.
I think I am doing something wrong but I cannot figure it out. Could you 
point out what  am I doing wrong in my program. 
Thank you for your help. 
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Oksijen Teknoloji
http://www.oksijen.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message