Ubuntu service not logging errors in a different file

26 Views Asked by At

I have created a Telegram bot using Java and I'm hosting it in an Ubuntu server.

I configured the service with the following code:

[Unit]
Description=Telegram bot service daemon

[Service]
WorkingDirectory=/home/ubuntu/Telegram
ExecStartPre=/bin/touch /home/ubuntu/Telegram/errorlog
ExecStart=/usr/bin/java -jar /home/ubuntu/Telegram/TelegramBot.jar

StandardOutput=file:/home/ubuntu/Telegram/log
StandardError=file:/home/ubuntu/Telegram/errorlog

[Install]
WantedBy=multi-user.target

As you can see, StandardOutput and StandardError files are set to be different but when I start the daemon, I see that all the Java exceptions that occur, are logged in the log file instead of the errorlog file (which is always empty).

Why is this happening? How can I fix this?

0

There are 0 best solutions below