Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DailyRollingFileAppender  RSS feed

 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


In my standalone java application iam using log4j.xml tp generate logg file suppose iam working on 07-09-09 day, and i want this logger.log file to be daily bases , on every midnight of the day 12PM after triggering any event for log , logger.log file should be copied to logger.log.07-09-09 and for 08-09-09 logger.log a new copy should be created. But for me a new copy of Logger.log is being created but i cannoit see the rolledover log file i.e.. logger.log.07-09-09 in my path Folder or machine.

and here is my log4j.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>

<appender name="test" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="logger.log"/>
<param name="threshold" value="info"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="immediateFlush" value="true"/>


<param name="append" value="true"/>

<layout class="org.apache.log4j.PatternLayout">
<param name="conversionPattern" value="%d{dd-MM-yy HH:mm:ss}[%p] %F(%L) - %m%n"/>
</layout>
</appender>

<root>
<priority value="info"/>
<appender-ref ref="test"/>
</root>

</log4j:configuration>

in the above , is mine log4j.xml. it is daily rolling file appender.i tested in my machine.please help me immediately.i couldnt locate the backups.help will be highly appreciated.



Thanks Satya
 
Rob Spoor
Sheriff
Posts: 21114
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Other Open Source Projects.
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the update, but can i know where this is been moved to.

Thanks and regrads

Satya
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


do i need any other file to be added like properties file, or if any.

Thanks Satya
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try something like:

 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, i tried with this , even then same problem . i cannot see the backup files
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found the issue with taking backupfiles of logger
the problem actually lies in the log4j-1.2.8\org\apache\log4j\DailyRollingFileAppender.class
there is it trying to rename the File


after long research

and here it is the source in DailyRollingFileAppender.java inside rollOver() boolean result = file.renameTo(target);
if(result)
{
LogLog.debug(fileName + " -> " + scheduledFilename);
} else
{
LogLog.error("Failed to rename [" + fileName + "] to [" + scheduledFilename + "].");
}


i found the problem to be is, the file which iam trying to rename is being locked, so it is not allowing to rename the file, this will be freed after closing or ending the application only.

so how to rename the file , is it to create one more appender?




thanks
Satya
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, have you considered upgrading to log4j-1.2.14?
 
satya satish
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thank you, i tried with upgrading my log4j version fom 1.2.8 to 1.2.14 and even then same problem

log4j:ERROR Failed to rename [logger.log] to [logger.log.2009-09-09-15-33].

Thanks
Satyanarayana
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any updates on this.
Any clue how to fix this issue.
My self is trying to log in Filter(wepapplication - filter) class facing the similiar issue. Can any one please suggest solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!