A_Elric
A_Elric

Reputation: 3568

How do I get java to output to a log when run from a batch?

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.

Upvotes: 5

Views: 21824

Answers (1)

JohnnyO
JohnnyO

Reputation: 3068

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

Upvotes: 16

Related Questions