I am running java apps via systemd:
[Unit]
Description=test service
[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/testserver
WorkingDirectory=/opt/testserver
ExecStart=/usr/bin/java -jar /opt/testserver/test.jar
StandardOutput=syslog
StandardError=syslog
User=testserver
Group=testserver
SyslogIdentifier=testserver
[Install]
WantedBy=multi-user.target
I want to get stdout
in /opt/testserver/stdout.log
and stderr
in /opt/testserver/stderr.log
- any working options are acceptable (i.e. if possible to do through syslog
). If possible I want to avoid logging at least one of these in journald log.
Thanks...
I'm trying the following for Logstash to replace its init.d script. Basically, wrapping it with bash to provide stdout and stderr redirection. Not sure if this is quite what you want, or would want to use (it's not too hideous, but clearly not how systemd wants you to do it), but I needed something to make it start after Elasticsearch, and I didn't want my team to notice anything different about where the log files ended up, so hopefully this will tide me over until they provide one of their own:
Edit: I just realized I could create
/etc/systemd/system/logstash.service.d/after-es.conf
as follows and not have to rewrite their init.d script:Oh well, leaving the above in case it's useful.