Results 1 to 3 of 3
  1. #1
    vasanthj is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default log4j RollingFileAppender question

    Hello,

    I have a log4j property setting like this:

    log4j.appender.fai=org.apache.log4j.RollingFileApp ender
    log4j.appender.fai.file=/opt/wasprofile/appsrv/logs/fai/fai.log
    log4j.appender.fai.append=true
    log4j.appender.fai.layout=org.apache.log4j.Pattern Layout
    log4j.appender.fai.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
    log4j.appender.fai.MaxFileSize=2MB
    log4j.appender.fai.fileNamePattern=fai%i.log
    log4j.appender.fai.MaxBackupIndex=4

    Initially an fai.log is created when the server starts up. When this log reaches 2MB, it gets rolled over to fai.log.1 and fai.log starts logging the latest statements as expected. When fai.log reaches 2MB the next time, it's content gets rolled over to fai.log.1, whose contents in turn get rolled over to fai.log.2. This goes on.....

    So at any point of time, I see the following logs in my system:
    fai.log
    fai.log.1
    fai.log.2
    fai.log.3
    fai.log.4

    All this works perfectly for a while. Then all of a sudden, the 4 backup files get archived as the following four files for some reason:
    fai-log.1-2011-01-11.log
    fai-log.2-2011-01-11.log
    fai-log.3-2011-01-11.log
    fai-log.4-2011-01-11.log

    The next time fai.log gets to 2MB, it rolls over the contents to a new fai.log.1. This goes on fine again. So now I have the following files in the system:
    fai.log
    fai.log.1
    fai.log.2
    fai.log.3
    fai.log.4
    fai-log.1-2011-01-11.log
    fai-log.2-2011-01-11.log
    fai-log.3-2011-01-11.log
    fai-log.4-2011-01-11.log

    Again, a new set of archive files are created after a while. So eventually, my system runs out of disk space. How do I prevent the archiving process from happening?

    My application is running on a WAS 6.1 server that is hosted in a zLinux machine. Is this environment related?

    thanks.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    its as if something is sometimes invoking the TimeBasedRollingPolicy

    which might be the default if not specified in your log4j configs.

    Maybe add a

    log4j.appender.fai.rollingPolicy=FixedWindowRollin gPolicy

    to enforce the fixed roling of max file size as you want.

  3. #3
    vasanthj is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default

    Thanks for the suggestion. I tried that and it still doesn't work. This is the modified properties file:


    log4j.appender.fai=org.apache.log4j.RollingFileApp ender
    log4j.appender.fai.file=/opt/wasprofile/appsrv/logs/fai/fai.log
    log4j.appender.fai.rollingPolicy=FixedWindowRollin gPolicy
    log4j.appender.fai.append=true
    log4j.appender.fai.layout=org.apache.log4j.Pattern Layout
    log4j.appender.fai.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
    log4j.appender.fai.MaxFileSize=2MB
    log4j.appender.fai.MaxBackupIndex=4

    Any other suggestions?

Similar Threads

  1. log4j RollingFileAppender question
    By vasanthj in forum Advanced Java
    Replies: 0
    Last Post: 12-07-2010, 08:07 PM
  2. Log4J Question <moved>
    By razorSpirit in forum New To Java
    Replies: 2
    Last Post: 10-13-2010, 10:33 PM
  3. log4j RollingFileAppender missing files
    By razorSpirit in forum New To Java
    Replies: 0
    Last Post: 10-13-2010, 06:57 PM
  4. Replies: 1
    Last Post: 09-20-2010, 08:32 AM
  5. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 12:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •