Results 1 to 13 of 13
  1. #1
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default log4j log files are not getting rolled over

    I am using log4j in my project the log files are not getting over after the stipulated size of the log file is reached.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default log4j logfiles are not getting rolled over

    We have an application which uses log4j to log its log messages, we are using rolling file appender and the roll over size is 5MB.
    Every thing runs fine when we have only one instance of this application running. The file gets rolled over after crossing 5MB.
    We are facing a problem only when we start the same application two times (in two different JVMS). The log file does not get roll over even after crossing 5MB.

    We have this problem as two log 4j instances ( running in different JVMS) are accessing the same file in parallel. The case might be that log 4j has a file pointer which is not refreshed when another instance of log 4j (running in different JVM) updates the same file.
    Is there any way to refresh the PropertyConfigurator setting.
    Last edited by ajaykumar_mohini; 06-21-2008 at 02:31 PM.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    The reason here is that same log files are directed on different instance of your application. Try to make new log file structure for each instance.

  5. #5
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default log4j logfiles are not getting rolled over

    Hi Eranga can u please explain a bit more on this i couldn't get it.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Say you run the application. Logs start to writes on. Then you start the same application again, but it use the same log files too. What I try to say is, use different files for this.

    In such cases what I have done is change the file name with application start time or such similar detail which is specific to that time only.

  7. #7
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    Ajay, have you used appenders correctly?
    please post your log4j.properties !!
    i am the future

  8. #8
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default log4j logfiles are not getting rolled over

    These are my log4j properties



    log4j.appender.RF.MaxBackupIndex=5
    log4j.appender.RF.layout.ConversionPattern=%p %c %d{dd-MMM-yyyy HH\:mm\:ss}- %m%n
    log4j.appender.RF.layout=org.apache.log4j.PatternL ayout
    log4j.appender.RF.MaxFileSize=1MB
    log4j.appender.RF=org.apache.log4j.RollingFileAppe nder
    log4j.appender.RF.File=logs/mqadapter.log

    log4j.logger.com.boeing.dd2cai.common=INFO, RF
    log4j.additivity.com.boeing.dd2cai.common=false

  9. #9
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Smile log4j logfiles are not getting rolled over

    Hi Eranga,
    Thanks for the suggestion i am now creating different log files for different instances(there would be only one instance per jvm as it the class is singleton) and its rolling over fine.But the catch here is that every time i stop my jvm and start again then a new set of log files are created thiss may turnaround to be nightmare in the long run can u please suggest a workaround for this.

    With Kind Regards
    Ajay

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    In that way you have it. Is it really trouble for you? Actually all depends on your implementation. Say the log file size you defined 10MB, depends on the time take to reach that level you have a mess. That mean you have to formated your log records in shorter with most important data.

    Even for separate instance try to use the same log file for a day. For a day you can handle the file size. If the file size is exceeded make the second file of the first.

    I hope it's clear to you.

  11. #11
    raj@hcl is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    I m using RollingfileAppender to split log file, but log is getting rewritten to same file when it reached specifyed size in log4j.properites. I want log file get splited after certain size. plz suggest solution to it.
    Here is my log4j.properties file
    log4j.rootCategory=WARN, A1
    log4j.appender.A1=org.apache.log4j.RollingFileAppe nder
    log4j.appender.A1.File=topconfig.log
    log4j.appender.A1.MaxFileSize=10KB
    log4j.appender.A1.MaxBackupIndex=5

    .
    log4j.appender.A1.layout=org.apache.log4j.PatternL ayout
    log4j.appender.A1.layout.ConversionPattern=%d{ISO8 601} [%t] %-5p %c %l - %m%n

    log4j.category.com.techdata.topconfig=DEBUG

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Bad enough that the original double post went undetected. raj@hcl, Please stop resurrecting old threads.
    log4j log files are not getting rolled over

    db

  13. #13
    raj@hcl is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default log4j.......

    I m still searching for the solution, above post dont solve my problem....

Similar Threads

  1. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 12:23 AM
  2. Regarding Log4j
    By sidiq in forum New To Java
    Replies: 0
    Last Post: 04-07-2008, 07:35 PM
  3. log4j with Applet
    By sunjavaboy in forum Java Applets
    Replies: 0
    Last Post: 03-25-2008, 12:13 AM
  4. Log4j
    By chakri in forum New To Java
    Replies: 1
    Last Post: 02-08-2008, 10:15 PM
  5. Problems using log4j
    By fred in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 03:30 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
  •