> This is where I knew your name from... ;o) :-) It's a small world ...or is it big..?
> Yes you would need to be careful about introducing infinite looping. I > actually ran into this with JMS logging (JMS consumer tries to log errors > which go to JMS which it then tries to handle, etc). This is not only > possible while overriding sysout and syserr (although much easier). Just > need to be careful designing a logging set-up. > > For this in particular, you would need to implement an > org.apache.log4j.spi.ErrorHandler implementation to handle the situation > (org.apache.log4j.helpers.OnlyOnceErrorHandler _might_ suffice). This seems like something someone at sometime should take the time to put in the sandbox, is it not ? :) I have refrained from setting up System.out/err=>log4j due to the warnings and recommendations that this mailinglist includes....and I have not yet had the time to check if it would be failsafe....infinite loops and disktrashing is not well-seen in production environments :) /max > > HTH > > > |-----Original Message----- > |From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED] > |Sent: Monday, March 17, 2003 10:16 AM > |To: Log4J Users List > |Subject: Re: How to redirect System.err and System.out to log4j? > | > | > |And what happens if log4j fails to log something to the logger ? > |Will the suggested solution avoid going into an infinite > |loop when log4j > |tries to log the error to System.err ? > | > |/max > | > |----- Original Message ----- > |From: "Cakalic, James" <[EMAIL PROTECTED]> > |To: "Log4J Users List" <[EMAIL PROTECTED]> > |Sent: Monday, March 17, 2003 2:01 PM > |Subject: RE: How to redirect System.err and System.out to log4j? > | > | > |Try the LoggingOutputStream class in the contribs/JimMoore > |folder of the > |log4j release. I've had pretty good success with it. Once > |you have it in > |your project (you'll probably want to put it in one of > |your util or helper > |packages) usage is simple, as described in the javadoc: > | > |// make sure everything sent to System.err is logged > |Logger err = Logger.getLogger("SystemErr"); > |Priority warn = Priority.WARN; > |System.setErr(new PrintStream(new LoggingOutputStream(err, > |warn), true)); > | > |// make sure everything sent to System.out is logged > |Logger out = Logger.getLogger("SystemOut"); > |Priority info = Priority.INFO; > |System.setOut(new PrintStream(new LoggingOutputStream(out, > |info), true)); > | > |Logging events are recorded using the appenders and > |layouts defined in your > |configuration. The category/logger that will appear is > |SystemErr for > |anything written to System.err and SystemOut for whatever > |is written to > |System.out. > | > |Best regards, > |Jim Cakalic > | > |-----Original Message----- > |From: Steve Ebersole [mailto:[EMAIL PROTECTED] > |Sent: Friday, March 14, 2003 9:52 PM > |To: Log4J Users List > |Subject: Re: How to redirect System.err and System.out to log4j? > | > | > |You would need to wrap a Logger in a PrintStream, and then do: > | > |System.out = new MyPrintStreamWrappedLogger(); > | > |HTH > | > | > |----- Original Message ----- > |From: "Zsolt Koppany" <[EMAIL PROTECTED]> > |To: "Log4j-User" <[EMAIL PROTECTED]> > |Sent: Friday, March 14, 2003 3:49 PM > |Subject: How to redirect System.err and System.out to log4j? > | > | > |> Hi, > |> > |> > |> how can I redirect System.err and System.out to a log4j > |appender? In an > |> existing application there are System.out.println() > |instructions that I > |> would like to see in the log4j file. How can I do that? > |> > |> > |> Zsolt > |> > |> > |> > |> > |----------------------------------------------------------- > |---------- > |> 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] > | > | > |Confidentiality Warning: This e-mail contains information > |intended only for > |the use of the individual or entity named above. If the > |reader of this > |e-mail is not the intended recipient or the employee or > |agent responsible > |for delivering it to the intended recipient, any > |dissemination, publication > |or copying of this e-mail is strictly prohibited. The > |sender does not accept > |any responsibility for any loss, disruption or damage to > |your data or > |computer system that may occur while using data contained > |in, or transmitted > |with, this e-mail. If you have received this e-mail in > |error, please > |immediately notify us by return e-mail. Thank you. > | > | > |----------------------------------------------------------- > |---------- > |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] > | > > --------------------------------------------------------------------- > 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]
