将System.out.println重定向到日志 [英] Redirect System.out.println to log

查看:605
本文介绍了将System.out.println重定向到日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目测试套件中有大量使用

In my project test suite there is big usage of

System.out.println 

我正在尝试将这些输出重定向到日志文件(通过配置或单点而不重构整个项目),这样就可以禁用了提高绩效所必需的。我正在使用log4j进行日志记录。
有没有人知道这可能吗?如果是这样怎么办?
提前致谢。

I'm trying to redirect these output to log file (through configuration or from single point without refactoring whole project ) so that can be disabled when necessary to improve performance. I'm using log4j for logging. Does any one know is this possible ? if so how to do it ? Thanks in advance.

推荐答案

我的建议是尽可能重构。
如需可能的解决方案,请检查以下类似问题

My suggestion would be to refactor if possible. For a possible solution, check these similar questions

log4j redirect stdout to DailyRollingFileAppender

将System.out.println重定向到Log4J,同时保留类名信息

这篇关于将System.out.println重定向到日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆