Hi Ionel,
by System.setErr(PrintStream) and System.setOut(PrintStream) .
If you want to integrate that in log4j, I suggest that you either directly use these
commands in your application or extend a FileAppender so that during initialization
this methods are called with the files you want to write to.
Thus you can redirect System.out and System.err to a file of your choice. As long as
you use a 'normal' Stream like in
FileOutputStream fdout = new FileOutputStream(your/log/file);
BufferedOutputStream bos = new BufferedOutputStream(fdout, 128);
PrintStream ps = new PrintStream(bos, true);
System.setOut(ps);
you can't use certain advantages of special FileAppenders like
DailyRollingFileAppender. It will just write your Output to the specified file.
As an 'add-on' you could also PrintStream and use an appender internally in that
extended PrintStream (AppenderPrintStream) version.
Some sort of two-tier appending.
Tier-one : your 'DummyAppender' that merely sets err and out during initialization of
the appender to an AppenderPrintStream-Object
Tier-two : Within that AppenderPrintStream-Object every print is redirected to log4j
System.out.println then writes to AppenderPrintStream that internally uses another
Appender (could be a file, smtp, jdbc or whatever appender.)
Hope that helps
Gy�rgy
-----Urspr�ngliche Nachricht-----
Von: Ionel GARDAIS [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 25. August 2004 13:42
An: [EMAIL PROTECTED]
Betreff: catching System.out and System.err into log4j
Hi there,
Someone else askes this but I did not saw any
response.
Is it possible to seemlessly catch System.out and
System.err and redirect to log4j ?
thanks,
ionel
Vous manquez d'espace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Cr�ez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Le nouveau Yahoo! Messenger est arriv� ! D�couvrez toutes les nouveaut�s pour
dialoguer instantan�ment avec vos amis. A t�l�charger gratuitement sur
http://fr.messenger.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]