1

I have very big java web applications deployed on IBM Websphere 7 and all of the exception catching blocks uses System.out.println to log the exceptions, all the output of System.out.println of the all applications deployed on WAS profile is printed in WAS SystemOut.log file.

I need to make every application on WAS log to a different log file not to SystemOut.log.

Log4j is not integrated with the applications and enabling it will take a long time.

Is there any technique to change the output destination of System.out.println for each application on WAS?

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
aomar
  • 500
  • 1
  • 6
  • 23

3 Answers3

1

all of the exception catching blocks uses System.out.println to log the exception

Don't do this! Use a logging framework.

Log4j is not integrated with the applications and enabling it will take a long time.

Well, then find the guy who build such a crappy application and make him implement the necessary changes.

  • 1
    If you read what aomar wrote, it's application*s*. Plural. There are numerous applications, all deployed in one container, all logging to standard output. The mine of WTF just gets deeper and deeper. – Tom Anderson Nov 08 '12 at 11:49
1

in this answered thread, the solution depends on overriding the out object of the System class to make use the log4j appender and i think its a nice idea

StdOutErrLog

Community
  • 1
  • 1
aomar
  • 500
  • 1
  • 6
  • 23
  • 1
    Yes, but again that will send all `System.out` and `System.err` output for the entire JVM to the same file. The OP wants it separated per-webapp. – Ian Roberts Nov 08 '12 at 11:06
0

You can change where System.out and System.err go on a global basis as pointed out by a comment on your question, but if you want to do it on a per-app basis the only solution I can think of would be to use an AOP framework such as AspectJ to intercept all the println calls within the relevant classes and direct them to a logger specific to the class in question.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183