Hola,
That's a fine generic way.  If you want to take advantage of log4j options,
you can create a WriterAppender that writes to the same PrintStream (ps) in Michal's 
code below.  Then your loggers can write to this appender and they don't need to know 
of the fdout part.

If you're on unix, there's also the classic 2&1-style redirection commands. These have 
nothing to do with log4j per-se.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Michal Ziv [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, August 25, 2004 8:38 AM
>To: Log4J Users List
>Subject: Re: catching System.out and System.err into log4j
>
>hi,
>I simply use this:
>         FileOutputStream fdout = new FileOutputStream(path/to/log/file);
>         BufferedOutputStream bos = new BufferedOutputStream(fdout, 128);
>         PrintStream ps = new PrintStream(bos, true);
>         System.setOut(ps);
>and the same err
>       System.setErr(ps);
>hope it helps
>michal
>
>On Wednesday 25 August 2004 14:42, Ionel GARDAIS wrote:
>>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]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to