When in bash I can run:
java -jar server.jar &>> log.txt
And it combines the stdout and stderr into log.txt
. However when I have this line in my Upstart .conf
file, it does not do this:
exec java -jar server.jar &>> log.txt
I’ve also tried separating the logs as:
exec java -jar server.jar >> log.txt 2>> err.txt
And this doesn’t work either. It will work if I make it overwrite instead of append, e.g.
exec java -jar server.jar > log.txt 2> err.txt
But this is not acceptable. Is this a bug in Upstart or is there something I’m misunderstanding? I’m running Ubuntu 14.04.2 LTS, Upstart version 1.12.1, and I’m fairly new to both.
Don't create the file yourself. Let upstart manage this so it will log both stdout and stderr to
/var/log/upstart/<service>.log
:If you need to change the directory path you can use
--logdir <directory>
.