Menu

#124 rolling file appenders sharing a log file

closed-wont-fix
nobody
None
5
2012-10-09
2009-08-20
No

When two or more rolling file appenders are sharing the same logfile then logging is working not as expected. Logging files will be rolled at unexpected size and logging will still be done on artifact files *.1, *.2 a.s.o.
The problem is that all appenders are rolling independed of each other. When the first has done the rolling, all others are operation on an obsolete log file / fd. A possible solution would be to let other appenders reload their fd after each rollover.

Discussion

  • Thomas Wabner

    Thomas Wabner - 2009-09-07

    can you please attach a small example with two rolling file appenders on the same logfile?

     
  • Robert Fichtner

    Robert Fichtner - 2009-09-08

    Here the configuration of two different rolling appenders logging into the same file (...summ.log) even if the size setting is equal.
    appender FWFMO.FWCNF basic rolling /opt/appl/data/log/summ.log 5000000 7
    priority FWFMO.FWCNF INFO

    appender FWFMO.FWPWR basic rolling /opt/appl/data/log/summ.log 5000000 7
    priority FWFMO.FWPWR DEBUG

    Scenario: the firts appender will rollover when the size threshold is crossed. As result, the second appenders fd will be pointing to summ.log.1 (!). Then it will write there a new log message and encounter the size threshold over limit. Then it will rollover even when the summ.log is not full, a.s.o.
    Also please look at RollingFileAppender::rollover().

     
  • Alexander Perepelkin

    Two file appenders are not really supposed to share a single output file.
    If you want to log from different places/threads, that is better achieved with sharing a single appender (and optionally using NDC feature).

     
  • Alexander Perepelkin

    • status: open --> closed-wont-fix
     

Log in to post a comment.

MongoDB Logo MongoDB