Ok,

but how will be the messages stored into Log4j?

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Davor Cengija
Sent: Samstag, 15. Marz 2003 16:32
To: [EMAIL PROTECTED]
Subject: Re: How to redirect System.err and System.out to log4j?


Steve Ebersole wrote:

> You would need to wrap a Logger in a PrintStream, and then do:
>
> System.out = new MyPrintStreamWrappedLogger();
>

System.in/out/err are final.

Use System.setIn()/setErr()/setOut(). Javadoc says:

setOut

public static void setOut(PrintStream out)

    Reassigns the "standard" output stream.

    First, if there is a security manager, its checkPermission method is
called with a RuntimePermission("setIO") permission to see if it's ok to
reassign the "standard" output stream.

Parameters:
        out - the new standard output stream
Throws:
        SecurityException - if a security manager exists and its
checkPermission
        method doesn't allow reassigning of the standard output stream.
Since:
        JDK1.1
See Also:
        SecurityManager.checkPermission(java.security.Permission),
        RuntimePermission


There's also -D option for the virtual machine (-Dstderr=your.class... or
something like that) but I cannot remember it right now. Google will
probably help.
--
[EMAIL PROTECTED]


---------------------------------------------------------------------
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]

Reply via email to