如何从一个批处理中运行时,我得到Java来输出到日志? [英] How do I get java to output to a log when run from a batch?

查看:89
本文介绍了如何从一个批处理中运行时,我得到Java来输出到日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Ares.jar一个java文件每隔5分钟通过Windows计划任务运行时,该批次的呼叫:

  Java的罐子Ares.jar>> Ares.log

我没有看到任何错误输出,是有一些方法,使错误(通信System.err.println / exception.printStackTrace();)去到一个文件?

感谢。


解决方案

  Java的罐子Ares.jar> Ares.log 2  - ;&放大器; 1

此命令的第二部分将标准错误重定向到标准输出,确保同时出现在同一个文件。

如果你想在不同的文件定期日志和错误日志,只需使用:

  Java的罐子Ares.jar> Ares.log 2  - ; Ares.error.log

您可以得到这是可能的文档中,可以从微软的一切的全部细节:<一href=\"http://technet.microsoft.com/en-us/library/bb490982.aspx\">http://technet.microsoft.com/en-us/library/bb490982.aspx

I have a java file called "Ares.jar" that runs every 5 minutes via windows scheduled tasks, the batch calls:

java -jar Ares.jar >> Ares.log  

I'm not seeing any error output, is there some way to make the errors (system.err.println / exception.printStackTrace(); )go to a file?

Thanks.

解决方案

java -jar Ares.jar > Ares.log 2>&1 

The second part of this command will redirect stderr to stdout, ensuring that both appear in the same file.

If you want regular logs and error logs in separate files, just use:

java -jar Ares.jar > Ares.log 2>Ares.error.log

You can get the full details of everything that is possible in the documentation, available from Microsoft: http://technet.microsoft.com/en-us/library/bb490982.aspx

这篇关于如何从一个批处理中运行时,我得到Java来输出到日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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