It's hard to debug what the problem is since you didn't say what the error
is, but if it didn't exist before adding the given code then it might be
that you've got a bug in how you're setting up your logging and the error
messages from Log4j are therefore trying to write out to STDERR, which
causes infinate recursion.

To see if that's the problem, try doing this instead (assuming you're
running Log4j 1.1.1):

    public static void setErrOut()
        throws IOException
    {
        org.apache.log4j.helpers.LogLog.setQuietMode(true);

        PrintStream prt = new PrintStream(
                new LoggingOutputStream(
                    Category.getRoot(),
                        Priority.INFO), true);
 
        System.setOut(prt);
        System.setErr(prt);
    }


If that stops the infinate recursion (which I'm guessing is the problem, but
I don't know since you never said) then you have a problem in how you're
setting up your appenders.  Don't call setErrOut(), start up your
application with "-Dlog4j.configDebug=true" and it should tell you what the
problem is.

(I remember there was discussion about being able to change where LogLog
sends its messages -- and I thought I read that it had been done -- but I
can't find any code in LogLog that allows that.)

-Jim Moore


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Zsolt Koppany
Sent: Sunday, May 27, 2001 5:25 PM
To: LOG4J Users Mailing List
Subject: Re: Redirecting System.err and System.out


Hi Jim,

I have seen and tried your code from contrib but I could not get it
running. Here I attach the method I call but the application gets blocks
for a long time and then I get an exception

In the e-mail I read the discussion about such issues, but I did not
understand the discussion.


    public static void setErrOut()
        throws IOException
    {
        PrintStream prt = new PrintStream(
                new LoggingOutputStream(
                    Category.getRoot(),
                        Priority.INFO), true);
 
        System.setOut(prt);
        System.setErr(prt);
    }

Jim Moore wrote:
> 
> See the contribs/JimMoore directory in CVS.
> 
>
http://jakarta.apache.org/cvsweb/index.cgi/jakarta-log4j/contribs/JimMoore/
> 
> Please note that this should only be used to get messages sent to STDOUT
and
> STDERR in code that you have no control over.  The best mehod for code you
> control, by far, is to use the normal Log4j methods.
> 
> -Jim Moore
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Zsolt Koppany
> Sent: Sunday, May 27, 2001 11:59 AM
> To: [EMAIL PROTECTED]
> Subject: Redirecting System.err and System.out
> 
> Hi,
> 
> is it possible to redirect System.err and System.out? I would like to
> get the stackTrace messages logged too when an exception happens.
> 
> --
> Zsolt Koppany
> Intland GmbH www.intland.com
> Schulze-Delitzsch-Strasse 16
> D-70565 Stuttgart
> Tel: +49-711-7871080 Fax: +49-711-7871017
> 
> ---------------------------------------------------------------------
> 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]

-- 
Zsolt Koppany
Intland GmbH www.intland.com
Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart
Tel: +49-711-7871080 Fax: +49-711-7871017

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