I think I hit upon a similiar problem, and I have found a workaround.
My problem arose when using the DailyRollingFileAppender with Tomcat.
Whenever the webapp reloaded for any reason, the file the Appender was
writing to would apparently not get closed, and I would get the 
"log4j:ERROR Failed to rename....." message for every subsequent rollover
attempt.

The workaround I came up with was to set up a ServletContextListener. In
the contextDestroyed() method of the Listener, I call close() on all
Appenders
for the root logger.  With that change, the webapp now reloads and the 
DailyRollingFileAppender continues to roll.


Jeffrey Snyder
Sark, Inc.


 

----------------------------------------------------------------------------

I have found the problem now:

When using PropertyConfigurator.configureAndWatch(...), an instance of 
org.apache.log4j.helpers.FileWatchdog is instantiated
and started in a separate thread. Redeployment of the application (meaning
removal and 
deployment) does not remove this thread. So, after redeployment there are
two such 
threads in the server's VM instance. The second one cannot access (and
therefore not 
rename) the logfile, because it is locked by the remaining previous 
FileWatchDog-thread.

Tricky and dangerous: I am constantly producing dead threads in the server's
VM 
instance.

Now, I have to find out how I can remove this thread at destroy time of my
application 
...
If anybody knows how, please let me know.

-----Urspr�ngliche Nachricht-----
Von: Stefan Bayer [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 8. Januar 2003 17:24
An: Log4J Users List
Betreff: Re: Problems wit DailyRollingFileAppender


Have you checked if you have the reqired rights in the file system?

At 15:11 08.01.2003, you wrote:
>I am using Log4J version 1.2.7.
>
>My properties-file looks as follows:
>
>log4j.rootLogger=DEBUG, A1
>log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
>log4j.appender.A1.DatePattern='.'yyyy-MM-dd-HH-mm
>log4j.appender.A1.File=./log/Log4JTest.log
>log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>
># Print the date in ISO 8601 format
>log4j.appender.A1.layout.ConversionPattern=[%x] - %d [%t] %-5p %c - %m%n
>
>I am using log4j within a web application server (SAP Web AS).The logging 
>itself works fine.
>At rolling time, the following message occurs on the server process 
>console output:
>
>         log4j:ERROR Failed to rename [./log/Log4JTest.log] to 
> [./log/Log4JTest.log.2003-01-08-13-11].
>
>What could be the reason for this?
>
>Thanks in advance for any hint.
>
>Regards,
>HaJo Odlozinski
>
>
>
>
>
>--
>To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


ByTek - Stefan Bayer
Softwaresysteme

Reply via email to