#166 Closing DailyRollingFileAppender used by several loggers leaves empty files

v1.1.2
closed
7
2015-02-15
2013-06-11
No

Log4cplus 1.1.0 (downloaded zip from website). Windows 7 x64, Core i7 CPU. Used CMake 2.8.10 to generate a MSVS 2010 solution. Cmake config:

  • static libs
  • don't build test cases
  • disabled unicode (because my client application doesn't use it)

Then opened the Log4cplus solution in VS2010, disabled wchar_t as integrated type on loggingserver and the actual project (in debug and release config), because my client application uses Qt4. Then I built the "INSTALL" project for debug and release.

Client application:

  • Also disables wchar_t as integrated type. Static lib (debug/release) .lib is linked against as appropriate. (log4cplus.lib for release, log4cplusd.lib for debug).
  • Uses the following configuration:
    log4cplus.rootLogger = DEBUG, AutoARConsoleAppender
    log4cplus.appender.AutoARConsoleAppender = log4cplus::ConsoleAppender
    log4cplus.appender.AutoARConsoleAppender.layout = log4cplus::PatternLayout
    log4cplus.appender.AutoARConsoleAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n

    log4cplus.logger.AutoAR.Managers.Position = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.Managers.Orientation = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.Managers.HMD = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.Managers.Ladybug = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.Managers.Sensor = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.Managers.Render = DEBUG, AutoARDailyRollingFileAppender
    log4cplus.logger.AutoAR.GUI = TRACE

    log4cplus.appender.AutoARDailyRollingFileAppender = log4cplus::DailyRollingFileAppender
    log4cplus.appender.AutoARDailyRollingFileAppender.Schedule = DAILY
    log4cplus.appender.AutoARDailyRollingFileAppender.File = logs/ManagerActivity.log
    log4cplus.appender.AutoARDailyRollingFileAppender.Append = true
    log4cplus.appender.AutoARDailyRollingFileAppender.layout = log4cplus::PatternLayout
    log4cplus.appender.AutoARDailyRollingFileAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
    log4cplus.appender.AutoARDailyRollingFileAppender.MaxBackupIndex = 1

As you can see, all my manager loggers, right now, put their output to the same appender (I might change this in the future).

The issue is that there is a bug in log4cplus. When it shuts down, it iterates over the loggers, and for each logger it closes all appenders belonging to it. In my situation, the AutoARDailyRollingFileAppender is closed over and over again. Since this appender does some fancy stuff with renaming files to "current day", managing backups, etc, that logic breaks down and finally produces a bunch of empty files. E.g.

  • Starting the client application ("logs" directory is empty)
  • ManagerActivity.log is created, empty
  • Now I produce some log statements in my program, from different loggers (e.g. HMD-manager and Ladybug manager). ManagerActivity.log grows, with the corresponding log entries, as expected.
  • Now I close the program. I get these files: ManagerActivity.log, ManagerActivity.log.2013-06-11, ManagerActivity.log.2013-06-11.1 (all files are EMPTY)
  • Note that if I set log4cplus.configDebug = true in my config, I get this output:
    log4cplus: Entering ConsoleAppender::close()..
    log4cplus: Destroying appender named [AutoARConsoleAppender].
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
    log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].

Hope it helps.

Related

News: 2013/07/log4cplus-112-rc2

Discussion

  • Václav Haisman

    Václav Haisman - 2013-06-11
    • labels: --> v1.1.0
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -7,6 +7,8 @@
     Client application:
     - Also disables wchar_t as integrated type. Static lib (debug/release) .lib is linked against as appropriate. (log4cplus.lib for release, log4cplusd.lib for debug).
     - Uses the following configuration:
    +
    +~~~~
     log4cplus.rootLogger = DEBUG, AutoARConsoleAppender
     log4cplus.appender.AutoARConsoleAppender = log4cplus::ConsoleAppender
     log4cplus.appender.AutoARConsoleAppender.layout = log4cplus::PatternLayout
    @@ -27,6 +29,8 @@
     log4cplus.appender.AutoARDailyRollingFileAppender.layout = log4cplus::PatternLayout
     log4cplus.appender.AutoARDailyRollingFileAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
     log4cplus.appender.AutoARDailyRollingFileAppender.MaxBackupIndex = 1
    +~~~~
    +
    
     As you can see, all my manager loggers, right now, put their output to the same appender (I might change this in the future).
    
    @@ -37,6 +41,10 @@
     - Now I produce some log statements in my program, from different loggers (e.g. HMD-manager and Ladybug manager). ManagerActivity.log grows, with the corresponding log entries, as expected.
     - Now I close the program. I get these files: ManagerActivity.log, ManagerActivity.log.2013-06-11, ManagerActivity.log.2013-06-11.1 (all files are EMPTY)
     - Note that if I set log4cplus.configDebug = true in my config, I get this output:
    +
    +
    +
    +~~~~
     log4cplus: Entering ConsoleAppender::close()..
     log4cplus: Destroying appender named [AutoARConsoleAppender].
     log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    @@ -58,5 +66,7 @@
     log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
     log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
     log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
    +~~~~
    +
    
     Hope it helps.
    
    • assigned_to: Václav Zeman
     
  • Václav Haisman

    Václav Haisman - 2013-06-11
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,36 +1,38 @@
     Log4cplus 1.1.0 (downloaded zip from website). Windows 7 x64, Core i7 CPU. Used CMake 2.8.10 to generate a MSVS 2010 solution. Cmake config:
    +
     - static libs
     - don't build test cases
     - disabled unicode (because my client application doesn't use it)
    +
     Then opened the Log4cplus solution in VS2010, disabled wchar_t as integrated type on loggingserver and the actual project (in debug and release config), because my client application uses Qt4. Then I built the "INSTALL" project for debug and release.
    
     Client application:
    +
     - Also disables wchar_t as integrated type. Static lib (debug/release) .lib is linked against as appropriate. (log4cplus.lib for release, log4cplusd.lib for debug).
     - Uses the following configuration:
    
    -~~~~
    -log4cplus.rootLogger = DEBUG, AutoARConsoleAppender
    -log4cplus.appender.AutoARConsoleAppender = log4cplus::ConsoleAppender
    -log4cplus.appender.AutoARConsoleAppender.layout = log4cplus::PatternLayout
    -log4cplus.appender.AutoARConsoleAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
    -
    -log4cplus.logger.AutoAR.Managers.Position = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.Managers.Orientation = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.Managers.HMD = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.Managers.Ladybug = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.Managers.Sensor = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.Managers.Render = DEBUG, AutoARDailyRollingFileAppender
    -log4cplus.logger.AutoAR.GUI = TRACE
    -
    -log4cplus.appender.AutoARDailyRollingFileAppender = log4cplus::DailyRollingFileAppender
    -log4cplus.appender.AutoARDailyRollingFileAppender.Schedule = DAILY
    -log4cplus.appender.AutoARDailyRollingFileAppender.File = logs/ManagerActivity.log
    -log4cplus.appender.AutoARDailyRollingFileAppender.Append = true
    -log4cplus.appender.AutoARDailyRollingFileAppender.layout = log4cplus::PatternLayout
    -log4cplus.appender.AutoARDailyRollingFileAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
    -log4cplus.appender.AutoARDailyRollingFileAppender.MaxBackupIndex = 1
    -~~~~
    -
    +~~~~~
    +    log4cplus.rootLogger = DEBUG, AutoARConsoleAppender
    +    log4cplus.appender.AutoARConsoleAppender = log4cplus::ConsoleAppender
    +    log4cplus.appender.AutoARConsoleAppender.layout = log4cplus::PatternLayout
    +    log4cplus.appender.AutoARConsoleAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
    +    
    +    log4cplus.logger.AutoAR.Managers.Position = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.Managers.Orientation = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.Managers.HMD = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.Managers.Ladybug = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.Managers.Sensor = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.Managers.Render = DEBUG, AutoARDailyRollingFileAppender
    +    log4cplus.logger.AutoAR.GUI = TRACE
    +    
    +    log4cplus.appender.AutoARDailyRollingFileAppender = log4cplus::DailyRollingFileAppender
    +    log4cplus.appender.AutoARDailyRollingFileAppender.Schedule = DAILY
    +    log4cplus.appender.AutoARDailyRollingFileAppender.File = logs/ManagerActivity.log
    +    log4cplus.appender.AutoARDailyRollingFileAppender.Append = true
    +    log4cplus.appender.AutoARDailyRollingFileAppender.layout = log4cplus::PatternLayout
    +    log4cplus.appender.AutoARDailyRollingFileAppender.layout.ConversionPattern=%D{%H:%M:%S.%q} %-5p [%c] %l %M %m %n
    +    log4cplus.appender.AutoARDailyRollingFileAppender.MaxBackupIndex = 1
    +~~~~~
    
     As you can see, all my manager loggers, right now, put their output to the same appender (I might change this in the future).
    
    @@ -42,30 +44,28 @@
     - Now I close the program. I get these files: ManagerActivity.log, ManagerActivity.log.2013-06-11, ManagerActivity.log.2013-06-11.1 (all files are EMPTY)
     - Note that if I set log4cplus.configDebug = true in my config, I get this output:
    
    -
    -
     ~~~~
    -log4cplus: Entering ConsoleAppender::close()..
    -log4cplus: Destroying appender named [AutoARConsoleAppender].
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    -log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    -log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
    -log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
    +    log4cplus: Entering ConsoleAppender::close()..
    +    log4cplus: Destroying appender named [AutoARConsoleAppender].
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log.2013-06-11 to logs/ManagerActivity.log.2013-06-11.1
    +    log4cplus: Renaming file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Renamed file logs/ManagerActivity.log to logs/ManagerActivity.log.2013-06-11
    +    log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
    +    log4cplus: Destroying appender named [AutoARDailyRollingFileAppender].
     ~~~~
    
     
  • Václav Haisman

    Václav Haisman - 2013-06-17

    This should be fixed by the attached patch against 1.1.x branch.

     
  • Václav Haisman

    Václav Haisman - 2013-06-17
    • labels: v1.1.0 --> v1.1.0, fixed
    • status: open --> closed
    • Group: v1.1.x --> v1.1.2
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks