Spring Boot 应用程序作为 systemd 服务:日志文件

Dav*_*nes 4 logging debian spring systemd spring-boot

我知道可以从 Spring Boot 应用程序创建一个可用作 systemd 服务的 jar。我使用手册从我在 Debian Jessie OS 上的应用程序创建 systemd 服务。Eveyrthing 工作正常,但我找不到如何将日志写入 /var/syslog 的单独文件的方法。正如文档所说:

请注意,与作为 init.d 服务运行时不同,运行应用程序的用户、PID 文件和控制台日志文件在 systemd 下的行为不同,必须使用“服务”脚本中的适当字段进行配置。有关更多详细信息,请参阅服务单元配置手册页。

它应该在 *.service 文件中配置,但我找不到任何合适的选项。有人在这个问题上有任何经验吗?

Iss*_*TIF 5

使用sh进程运行服务

[Service]
ExecStart=/bin/sh -c "/var/myapp/myapp.jar >> /var/logs/myapp.log"
KillMode=control-group
Run Code Online (Sandbox Code Playgroud)

在 influxdb github repo https://github.com/influxdata/influxdb/issues/4490 中看到这个讨论