• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting sysout to log file

 
Midhun Agnihotram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

We have a Spring and Hibernate based J2EE application. Even though there is a logger mechanism created using log4j, many System.out.println statements are used.

As per my knowledge, Sysouts effect the performance of the application. Is there a way to redirect all Sysouts to the logger file so that it boost the performance a bit ? I donot want to change the Sysouts in all files as it is huge code base.

Thanks,
Midhun
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can redirect sysout and syserr using statments like: System.setOut(myPrintStream). There's a good discussion of it here: http://blogs.sun.com/nickstephen/entry/java_redirecting_system_out_and.

However, what would really be better is updating all those println()s to log() statements. Log4j will give you a lot more control over where the logs go and what they will contain.
 
Joe Ess
Bartender
Posts: 9297
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:Log4j will give you a lot more control over where the logs go and what they will contain.


Java has a built in logging API, in case you are wary of third parties (though I use Log4J myself).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic