我想知道是否有人知道eclipse的插件,它会在每一行控制台输出上放一个简单的时间戳.
我已经看过其他一些问题,这些问题的答案详细说明了如何通过代码本身在输出上启用时间戳,但是对于任何输出的每行输出都打印当前系统时间会很好.应用程序我决定在不需要代码编辑的情况下运行.
当然这是一个非常简单的功能?我错过了一些非常明显的东西吗?
编辑补充:我正在使用Eclipse Kepler.
在我看来,你有两种可能性。
可能性一
使用任何现有的日志框架。像slf4j、log4j和logback。
可能性二
您无法通过 来实现它System.out.println(),但您可以编写一个自定义打印机函数来为您完成这项工作。就像是
//Set any date format you would like here
private static DateFormat dateFormat = new SimpleDateFormat("yyyy MMM dd HH:mm:ss");
//Make calls to the method with the message that you want to print
private static void customDisplay(String message){
System.out.println("["+dateFormat.format(new Date())+"] " + message);
}
Run Code Online (Sandbox Code Playgroud)
因此,现在不要调用System.out.println(),而是调用您的方法
customDisplay("Some message that will be displayed with timestamp")
Run Code Online (Sandbox Code Playgroud)
编辑
据我所知,除了设置方案和一些颜色外观和感觉之外,我们无法对 Eclipse 的控制台输出进行太多配置。
| 归档时间: |
|
| 查看次数: |
1190 次 |
| 最近记录: |