Hi Jason,

What are your requirements for "reporting functions"?  Do you need to discover 
statistics about the current log file?  I'm guessing, but it seems that the 
most useful statistic might be the current size of the log file.  I've outlined 
a possible way you might be able to get at that.

The RollingFileAppender uses the org.apache.log4j.helpers.CountingQuietWriter 
to keep track of the number of characters written to the FileOutputStream.  
DailyRollingAppender doesn't use the CountingQuietWriter, it uses a QuietWriter 
instead.  So maybe you could extend DailyRollingAppender: you could override 
the setQWForFiles(:Writer) method to use the CountingQuietWriter instead of the 
QuietWriter.  At that point you may fairly easily expose a method that will 
give you the current character count.

NB the CountingQuietWriter is not thread-safe, so if you want to access this 
property of the appender from a separate thread, you'll have to provide a 
synchronized version of the CountingQuietWriter (I've already written one of 
these - let me know if you'd like the source).

Cheers,

Simon




________________________________
From: "ja...@web.de" <ja...@web.de>
To: log4j-user@logging.apache.org
Sent: Monday, 4 May, 2009 13:56:54
Subject: Access logfile logger

Hi,

I'm using log4j with a DailyRollingFileAppender. Now I want to add some 
reporting functions to the same application that uses this appender. So I need 
to get access to the logfile that is written by the file appender. Only the 
current logfile needs to be read so is is possible via the logger instance?

Logger logger = Logger.getLogger(this.class);

Regards,
Jason


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


      

Reply via email to