logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <ddek...@freemail.hu>
Subject How to make file appenders flush after each message?
Date Sun, 18 Sep 2011 17:46:03 GMT
I need log messages to appear in a log file without no more than a few
seconds of delay. I have set "immediateFlush" and "bufferedIO" to
force that, but still the messages only appear in the file when I shut
down the whole app. What am I missing here?

I'm using Log4j 1.2.15, org.apache.log4j.FileAppender and this is the

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true">
  <appender name="testAppender" class="org.apache.log4j.FileAppender">
    <param name="file" value="D:/aa/Prog/Works/foek/nemsitt.hu/project/log/t" />
    <param name="immediateFlush" value="true" />
    <param name="bufferedIO" value="false" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%t] %c - %m%n" />

    <priority value="info" /> 
    <appender-ref ref="testAppender" />


and the debug output is:

log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Level value for root is  [info].
log4j: root level set to INFO
log4j: Class name: [org.apache.log4j.FileAppender]
log4j: Setting property [file] to [D:/aa/Prog/Works/foek/nemsitt.hu/project/log/
log4j: Setting property [immediateFlush] to [true].
log4j: Setting property [bufferedIO] to [false].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d %-5p [%t] %c - %m%n].
log4j: setFile called: D:/aa/Prog/Works/foek/nemsitt.hu/project/log/t, true
log4j: setFile ended
log4j: Adding appender named [testAppender] to category [root].
log4j: Reading configuration from URL file:/D:/aa/Prog/Works/foek/nemsitt.hu/pro
log4j: Could not find root logger information. Is this OK?
log4j: Finished configuring.

(BTW I also don't yet know why does it say that I have no root logger
info... but that's another mater.)

Best regards,
 Daniel Dekany

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

View raw message