I have a systemd service:

Description=My application

ExecStart=/bin/java myapp.jar

There is an option: StandardOutput= but I don't understand how to use it to write to a file. https://www.freedesktop.org/software/systemd/man/systemd.exec.html

I was expecting to put a filepath somehere but the documentation talks about sockets and file descriptors. seems it needs more configuration than just that keyword.

Where to put the filepath ? I can't find any examples of that use


  • 2
    This is a duplicate of Redirect systemd service logs to file... However, the answer there does not answer your question (it doesn't answer the duplicate question either). You might find this answer useful... Dec 5, 2017 at 13:16
  • my workaround: create a shell launcher that redirect stdout to file and launch that script through systemd.
    – exeral
    Dec 13, 2017 at 13:23
  • @exeral There is also a StandardOutput=file:/path/to/here.log option.
    – peterh
    Feb 6, 2019 at 10:27
  • yea, seems it would do the job now. this feature was added in v236, few days later..!
    – exeral
    Feb 6, 2019 at 13:50
  • 1
    Does this answer your question? redirect systemd service logs to file
    – Cirelli94
    May 28, 2021 at 10:14

2 Answers 2



Description=My application

ExecStart=/usr/bin/java -jar myapp.jar

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:

Description=My application

ExecStart=/usr/bin/sh -c 'exec /usr/bin/java -jar myapp.jar'

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=.

  • 5
    what about append: instead of file:? Jan 29, 2019 at 16:55
  • 11
    It is worth mentioning append: is available only in systemd 240+.
    – Hindol
    Nov 27, 2019 at 13:12
  • 3
    Also file: is only available in 236+. You can find the version with systemctl --version. At time of writing Amazon Linux 2 ships with 219...
    – a-h
    Feb 25, 2021 at 13:57

If your app is a Python script you also need to set


Otherwise you will not see any log messages until the buffer is flushed.

  • 2
    I realize this doesn't answer the original question, but as somebody searching for why my (python-based) service isn't logging stdout, this solves my problem. May 18, 2021 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .