DavyJohnes
DavyJohnes

Reputation: 321

Spring Boot application as a systemd service: log file

I know it is possible to create a jar from Spring Boot application which can be used as a systemd service. I used this manual to create systemd service from my application on Debian Jessie OS. Eveyrthing works fine, but I can't find a way how to write logs to separate file insted of /var/syslog. As documentation says:

Note that unlike when running as an init.d service, user that runs the application, PID file and console log file behave differently under systemd and must be configured using appropriate fields in ‘service’ script. Consult the service unit configuration man page for more details.

it should be configured in *.service file, but I can't find any appropriate options. Has someone any experience in this question?

Upvotes: 7

Views: 9281

Answers (1)

Issam El-atif
Issam El-atif

Reputation: 2486

Run the service with a sh process

[Service]
ExecStart=/bin/sh -c "/var/myapp/myapp.jar >> /var/logs/myapp.log"
KillMode=control-group

See this discussion in influxdb github repo https://github.com/influxdata/influxdb/issues/4490

Upvotes: 6

Related Questions