systemd: how to redirect stdout to logfile

Use:

[Unit]
Description=My application

[Service]
ExecStart=/usr/bin/java -jar myapp.jar
Type=simple
User=photo
StandardOutput=file:/var/log/logfile

as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=

Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error systemd directives do not support appending to files.

If you want to maintain file log between service restarts and just append new logged lines to it, use instead:

[Unit]
Description=My application

[Service]
ExecStart=/usr/bin/sh -c 'exec /usr/bin/java -jar myapp.jar'
Type=simple
User=photo

exec means that shell program will be substituted with /bin/java program after setting up redirections without forking. So there will be no difference from running /bin/java directly after ExecStart=.