logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ja...@web.de
Subject Access logfile logger
Date Wed, 06 May 2009 06:42:51 GMT
Hi Heri,

that is exactly I was searching for. Thank you for your advise. It works perfect.



You cannot get access to the file object itself for reading purpose because the FileAppender
uses a FileWriter class for writing to the file. But you can learn the file name where the
appender writes to.
Not each logger instance which you get by Logger.getLogger() has appenders attached. Only
the logger instances whose name is exactly as a configured one have in fact the appenders
attached as configured. So, if your logger instance has no RollingFileAppender attached, you
would have to ask the parent logger, and so on, until you find the desired appender.
Since the appenders instances are singleton, it would be easier to ask the LogManager for
all appenders and iterate on these to find your desired RollingFileAppender. Once you have
found the correct appender instance, you cast it and ask it for the file name for use in a
file reader object.
I am not sure about the lock mechanisme applied by a RollingFileAppender, if there are any.
You have to try.
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört? 
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123

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

View raw message