This is my case:
Even though the command I run is not so relevant, I’ll still include it.
user@machine:$ java -classpath /home/user/mysql.jar:/home/user/jericho-html.jar:/home/user JavaFile
I have introduced an error in the java code, so the command gives the output:
[ERROR] null
Exception in thread "main" java.lang.Exception
[ERROR] input:
null
at JavaFile.main(JavaFile.java:111)
What I want to achieve is to write this output to a file, and then to send the file to my e-mail address. I’ve sorted the e-mail stuff out, but I can’t figure out how to write this output to a file.
I’ve tried adding >> filename.txt to the end of the command, but that does nothing. And I can’t locate the java log files on the system, if they even exist.
You have to redirect stderr to your file. Use
&>>instead>>for redirection. That way you will redirect all output (stderr and stdout).