2

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.

Dax Fohl
  • 283
  • 1
  • 2
  • 7

1 Answers1

2

Don't create the file yourself. Let upstart manage this so it will log both stdout and stderr to /var/log/upstart/<service>.log :

console log
exec java -jar server.jar

If you need to change the directory path you can use --logdir <directory>.

Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50