简体   繁体   English

更改 WAS 7 上特定 Web 应用程序的 System.out.println 输出目标

[英]Changing the System.out.println output destination for a specific web application on WAS 7

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.我在 IBM Websphere 7 上部署了非常大的 Java Web 应用程序,所有异常捕获块都使用 System.out.println 来记录异常,部署在 WAS 配置文件上的所有应用程序的 System.out.println 的所有输出都打印在WAS SystemOut.log 文件。

I need to make every application on WAS log to a different log file not to SystemOut.log.我需要将 WAS 上的每个应用程序记录到不同的日志文件而不是 SystemOut.log。

Log4j is not integrated with the applications and enabling it will take a long time. Log4j 未与应用程序集成,启用它需要很长时间。

Is there any technique to change the output destination of System.out.println for each application on WAS?是否有任何技术可以为 WAS 上的每个应用程序更改 System.out.println 的输出目标?

all of the exception catching blocks uses System.out.println to log the exception所有异常捕获块都使用 System.out.println 来记录异常

Don't do this!不要这样做! Use a logging framework.使用日志框架。

Log4j is not integrated with the applications and enabling it will take a long time. Log4j 未与应用程序集成,启用它需要很长时间。

Well, then find the guy who build such a crappy application and make him implement the necessary changes.好吧,然后找到构建如此糟糕应用程序的人并让他实施必要的更改。

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在这个回答的线程中,解决方案取决于覆盖 System 类的 out 对象以使用 log4j appender,我认为这是一个好主意

StdOutErrLog 标准输出错误日志

正如对您的问题的评论所指出的那样,您可以更改 System.out 和 System.err 在全球范围内的位置,但是如果您想在每个应用程序的基础上进行更改,我能想到的唯一解决方案是使用AOP 框架(如 AspectJ)拦截相关类中的所有 println 调用,并将它们定向到特定于相关类的记录器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM