I just browsed log4j's documentation a little, and came across their
"ExternallyRolledFileAppender". 
It is a file appender that listens to a port, and when a certain signal
comes through, it rolls the file (i.e. closes the current file, renames it
and starts over with a new file).
I guess this is the Windows alternative to sending a HUP signal.

To make it work, you would have some sort of external log rotation tool, and
a small command line app thats sends the rotation signal.
The complexity of the log rotation tool could be arbitrary. It could also be
as simple as a windows script.

What do you think about such a solution?

/Göran

-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED] 
Sent: den 3 mars 2006 15:09
To: Log4NET User
Subject: RE: Compression tool

The main problem with this approach (rolling with an external tool, e.g.
Logrotate or Rotetelog) on Windows is that files open for writing are locked
and cannot be renamed. On UNIX based file systems you can rename a file
while it is locked and the application will continue to write to it.
Typically after renaming the log file you would send the application a HUP
signal to cause it to close the current log file and open a new log file
with the original name. There is no standard way of signalling applications
in Windows.

Personally I think that the current RollingFileAppender is too complex and
we would benefit greatly from a more pluggable approach similar to the new
implementation in log4j:

http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apache/lo
g4j/rolling/

At least with a plugin model it would be simpler for users to define their
own behaviours when the out of the box solution does not fit.

Cheers,
Nicko

Reply via email to