[logback-user] how to redirect system.out/err to a file?

Zhangguangchao zhangguangchao at huawei.com
Thu Jul 21 09:03:57 CEST 2011


Hi, David,
  Thanks for your information, it helps a lot.
  
 But it  seems that sysout-over-slf4j has not supported OSGi yet. And I can't redirect the system.out/err from various bundle which has its own classloader in OSGi environment.  If sysout-over-slf4j works like log4j-over-slf4j, that will be very cool.

Do you have any other advice ? Thanks.

Another question is when I redirect felix-main system.out  into a file,  it casts an exception as follows:

2011-07-21 14:21:48,142 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] Exception in thread "Felix Shell TUI" java.lang.OutOfMemoryError: Java heap space
2011-07-21 14:21:48,143 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at java.util.Arrays.copyOf(Arrays.java:2882)
2011-07-21 14:21:48,143 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
2011-07-21 14:21:48,143 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
2011-07-21 14:21:48,143 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at java.lang.StringBuilder.append(StringBuilder.java:119)
2011-07-21 14:21:48,143 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at uk.org.lidalia.sysoutslf4j.context.LoggerAppenderImpl.append(LoggerAppenderImpl.java:52)
2011-07-21 14:21:48,144 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at uk.org.lidalia.sysoutslf4j.system.SLF4JPrintStreamDelegate.delegatePrint(SLF4JPrintStreamDelegate.java:68)
2011-07-21 14:21:48,144 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at uk.org.lidalia.sysoutslf4j.system.SLF4JPrintStreamImpl.print(SLF4JPrintStreamImpl.java:251)
2011-07-21 14:21:48,144 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:133)
2011-07-21 14:21:48,144 ERROR [Felix Shell TUI] java.lang.ThreadGroup [LogLevel.java:88] 	at java.lang.Thread.run(Thread.java:619)

And in the log file there are lots of '>' which appears on the felix terminal console. It seems that '>' is printed by felix and then redirected to sysout-over-slf4j. However it has too many '>' and SLF4JPrintStreamImpl goes down. Am I right?
Is this a bug of sysout-over-slf4j?

Here is a list I use: felix 3.2.0, slf4j-api-1.6.1, logback-* -0.9.28 and sysout-over-slf4j-1.0.2. 
Any advice?


From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] 代表 David Roussel
at: 2011年7月20日 2:57
Receiver: logback users list
Subject: Re: [logback-user] how to redirect system.out/err to a file?

Dominic,

That work mentioned by rob was done, and he sent a notification to this this a while back.

You can find all the instructions here: http://projects.lidalia.org.uk/sysout-over-slf4j/

There are some restrictions, so do read the docs.

David

On 19 Jul 2011, at 07:42, Zhangguangchao wrote:



Hi,
Is there a configuration to redirect STDOUT to a file?
By the way, I found the same question asked in http://www.qos.ch/pipermail/logback-user/2009-June/001141.html and I wanna know whether it is fixed and how. And I didn't found the new feature about ConsoleAppender configuration changed in Logback News.

Thanks a lot.

Dominic Zhang

_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user



More information about the Logback-user mailing list