开发者

Java redirect exception to file

I want to redirect FULL output of my program to a file (including Exceptions) in bash. I can't change content of class. I run it like that:

java -Djava.security.manager -Djava.sec开发者_开发问答urity.policy=JLPPolicy -Xmx16M -Xms2M -cp /var/tomcat/bin/ Main > File

Exceptions are send to console, which is bad for me. Can I do something with it?


Assuming you're using bash you can run the command with 2>&1 appended to the end of the command; e.g

> File 2>&1

This will redirect file descriptor #2 (stderr) into file descriptor #1 (stdout) which you've already directed to the named file.

You could also try:

>& File

... which should direct both stdout and stderr.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜