Actually, I avoided the formatting issue, by writing directly to the lower
level stream, which is why the rolling which is detected at the higher level
does not work exactly as desired.

What version is your extension in?  I was just working with the 1.2.7
base...

Thanks

Rich Gibbs

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 1:42 PM
To: Log4J Developers List
Cc: Log4j-Dev (E-mail)
Subject: Re: Rolling appender, that contains standard err/out



Rich,
I extended PrintStream to accept a Logger and priority on the constructor.
The write(String) and print(Object) methods are overriden to call log4j.
All other methods are overriden to call one of those 2.  I extended log4j
configuration to accept a property, if set to true then:

      System.setOut(new Log4JPrintStream(Logger.getLogger("System.Out"),
Priority.NORMAL));
      System.setErr(new Log4JPrintStream(Logger.getLogger("System.Err"),
Priority.ERROR));

You'll need a "NullOutputStream" object to pass to the constructor of
PrintStream during the super call in the Log4JPrintStream constructor.  It
overrides OutputStream methods with no-ops.

This works for any appender and in your case will definitely roll when it
should.  Only drawbacks are formatting when making multiple calls to
System.out and expecting it to be 1 message, but then again you probably
have that issue now.

Chris

Reply via email to