Similar to that, in the contribs area of CVS there's a utility class
for doing the redirect:
http://cvs.apache.org/viewcvs.cgi/logging-log4j/contribs/JimMoore/LoggingOutputStream.java


On Wed, 25 Aug 2004 15:02:02 +0200, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> 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

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

Reply via email to