Results 1 to 2 of 2
  1. #1
    ashu_knw is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default Need to create the archieved file for all generated log file using log4j

    Hi,

    Suppose we have defined following log properties:

    log4j.appender.rolling=org.apache.log4j.RollingFil eAppender
    log4j.appender.rolling.File=<log file path>
    log4j.appender.rolling.MaxFileSize=10MB
    log4j.appender.rolling.MaxBackupIndex=10

    This will generated the 10 backup log file with each size of 10MB . After all 10 files got generated i will overwrite the last one menas old log got removed.

    My requirement is after all 10 files got generated, i need to archieved these file and after again new files get generate. so that we shuold not lose the log data.

    Please let me know ,how we can achieved this?

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    368
    Rep Power
    5

    Default

    Hello,

    this rolling file appenders can give you big headache in multithread part of you app. We could not handle them well so we decided to change approach.

    We use daily logging instead.

    If you don't log too many MBs in one day
    you may want to try it.

    This way you will have
    history of all your log files saved in daily folders.

    To test it run your app
    and change system date while app is running.
    You should get a new folder every time new date starts
    and loger continues to log in new daily file.

    Here is example and download link for src code
    if you decide to use this approach.

    Daily Folder Appender - CodeProject

    (registration is just 3 line form on this site before download :) )

    cheers!

Similar Threads

  1. log4j file location
    By Netzilla in forum New To Java
    Replies: 0
    Last Post: 03-17-2010, 03:00 PM
  2. retain value of input type file in a jsp file while being dynamically generated
    By nidhi c in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:21 AM
  3. Log4j - setting up name of log file
    By Virkant Pawar in forum New To Java
    Replies: 3
    Last Post: 06-03-2008, 07:39 AM
  4. log4j property file in my application
    By Peter in forum Advanced Java
    Replies: 3
    Last Post: 06-14-2007, 03:12 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
  •