Hello all. I am quite new to log4j, so please bear with me if I am on the
wrong track. Any feedback is welcome!
I found the KeyFileAppender from Yoav Shapira, Steve Ebersole in the net and
I was very happy with it.
So I started using it on my transaction server, using the transaction code
as a key and had all my transaction logging in files. I was really happy,
then.
But now, periodically, I have to shut down the server because the server (a
JBoss 4.0.4) keeps (if not all) a lot of open filehandlers, from past
transactions.
I need to solve this problem and I stumble on some problems. The transaction
does finish, and then I could close the logfile handler. How do I tell the
logger to close it? I thought about adding a new method to KeyFileAppender,
and the transact manager (which is my code) would have to cast the appender
that I get from the logger and make it close that given key, something like:
public void closeKeyFile(String key) {
QuietWriter writer = (QuietWriter)writers.get(key);
if (writer == null) return;
try {
writer.write( super.layout.getFooter() );
if (super.immediateFlush)
writer.flush();
writer.close();
}
catch(IOException e) {
LogLog.error("Could not close " + writer, e);
}
}
Is that correct? I fear that isn't ok, I don't know. Maybe there's a newer
KeyFileAppender somewhere that I don't know? Could you please tell?
And, if I must implement that, I have one doubt. If I have to restart the
transaction, a new Writer will be created? I think so, but...?
Another idea would be to 'timeout' a writer, but that would require period
checks somewhere in the logging system. Where do I put them? I really don't
know, and I don't like the idea of creating a new thread
Thanks in advance,
Leo.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]