The systemd version in CentOS 7 (version 219) does not support the StandardOutput=file:...
/StandardError=file:...
syntax, which was only added in systemd version 236:
StandardOutput=
Controls where file descriptor 1 (STDOUT) of the executed processes is connected to. Takes one of inherit, null, tty, journal, syslog, kmsg, journal+console, syslog+console, kmsg+console or
socket.
(from the systemd.exec man page in CentOS 7).
I think since you've not specified a valid value, the default value of journal
is used and the journal forwards everything to syslog:
journal connects standard output with the journal which is accessible
via journalctl(1). Note that everything that is written to syslog or
kmsg (see below) is implicitly stored in the journal as well, the
specific two options listed below are hence supersets of this one.
syslog connects standard output to the syslog(3) system syslog
service, in addition to the journal. Note that the journal daemon is
usually configured to forward everything it receives to syslog anyway,
in which case this option is no different from journal.
If you are able to modify the python application, you can use pythons logging module to log to a file:
import logging
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
logging.error('And non-ASCII stuff, too, like Øresund and Malmö')
/apps/mycode.py
is handling it's output. If the python script is sending output to the system log facilities, instead of standard out, you cannot redirect that. You will have to modify the python script to either output to the file you want, or give it some kind of command line parameter to do so--if the script supports such a command line./var/log/messages
unless it is specifically programmed to do so. So if you have output to the 'messages' log file, something is instructing it to. You need to find out what is doing that, and tell it to output to the file you want the output to appear in. While the same output may be appearing on your console, that usually means that it is being duplicated to your console, by various methods.