title: How can I log exception errors to disk of a systemd service?
body: <p>I have written below systemd service that runs the flask  app on gunicorn following a tutorial.
  I am able to see access logs in <code>/var/log/nginx/</code> but not log of error happening in the python flask app!
  How can I log errors to disk of a systemd service?</p>
  
  <pre><code>$ cat /etc/systemd/system/gunicorn.service                                          [Unit]
  Description=gunicorn daemon for /var/www/html/start_backend.py
  After=network.target
  
  [Service]
  PermissionsStartOnly = true
  User=ciasto
  Group=www-data
  RuntimeDirectory=gunicorn
  WorkingDirectory=/var/www/html/
  ExecStartPre = /bin/chown -R pi:www-data /var/www/html/
  Environment="APP_SETTINGS=production"
  Environment="DB_USER=username"
  Environment="DB_PWD=password"
  Environment="DB_HOST="ceres.local"
  ExecStart=/usr/bin/env gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4 start_backend:web_app
  ExecReload=/bin/kill -s HUP $MAINPID
  ExecStop=/bin/kill -s TERM $MAINPID
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>To get exception error logs I added below two lines:</p>
  
  <pre><code>StandardOutput=file:/var/log/gunicorn/log1.log
  StandardError=file:/var/log/gunicorn/log2.log
  </code></pre>
  
  <p>I restarted the gunicorn service than visited the URL to throw the exception error, check the path where I expect log to come . But I see nothing</p>
  
  <pre><code>sudo systemctl status  gunicorn                                 ● gunicorn.service - gunicorn daemon for /var/www/html/start_backend.py
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2019-01-03 22:42:31 IST; 1min 9s ago
    Process: 3944 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
    Process: 3947 ExecStartPre=/bin/chown -R ciasto:www-data /var/www/html/ (code=exited, status=0/SU Main PID: 3950 (gunicorn)
     CGroup: /system.slice/gunicorn.service
             ├─3950 /usr/bin/python /usr/bin/gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4            ├─3965 /usr/bin/python /usr/bin/gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4            ├─3966 /usr/bin/python /usr/bin/gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4            ├─3967 /usr/bin/python /usr/bin/gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4            └─3968 /usr/bin/python /usr/bin/gunicorn --bind=unix:/tmp/gunicorn.sock --workers=4 
  Jan 03 22:43:34 ceres env[3950]:     db.connect()
  Jan 03 22:43:34 ceres env[3950]:   File "/home/ciasto/.local/lib/python2.7/site-packages/peewee.py"Jan 03 22:43:34 ceres env[3950]:     self._state.set_connection(self._connect())
  Jan 03 22:43:34 ceres env[3950]:   File "/home/ciasto/.local/lib/python2.7/site-packages/peewee.py"Jan 03 22:43:34 ceres env[3950]:     return mysql.connect(db=self.database, **self.connect_paraJan 03 22:43:34 ceres env[3950]:   File "/home/ciasto/.local/lib/python2.7/site-packages/MySQLdb/__Jan 03 22:43:34 ceres env[3950]:     return Connection(*args, **kwargs)
  Jan 03 22:43:34 ceres env[3950]:   File "/home/ciasto/.local/lib/python2.7/site-packages/MySQLdb/coJan 03 22:43:34 ceres env[3950]:     super(Connection, self).__init__(*args, **kwargs2)
  Jan 03 22:43:34 ceres env[3950]: TypeError: connect() argument 1 must be string, not None
  ciasto@ceres:/etc/systemd/system $ cd /var/log/gunicorn                                            ciasto@ceres:/var/log/gunicorn $ ll
  total 0
  ciasto@ceres:/var/log/gunicorn $
  </code></pre>