Logging with systemd

You can set your local timezone to look at the files in a sensible way. Everything is stored in UTC.

timedatectl list-timezones
sudo timedatectl set-timezone America/Los_Angeles
timedatectl status
      Local time: Wed 2018-04-18 11:34:46 PDT
  Universal time: Wed 2018-04-18 18:34:46 UTC
        RTC time: Wed 2018-04-18 18:34:45
       Time zone: America/Los_Angeles (PDT, -0700)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

You can see all the ‘units’ that you have using the following command. If you don't have your process running with a systemd unit file, you won't see it in this list. Don't fret, you can still see logs from those processes that are not managed by systemd but that are still journaling.

systemctl list-unit-files --all | grep flow
flowmojo.com.service                       disabled

You can see here that my process is not enabled to boot, but it will still log to the journal if it is started.

If you find the service listed in the unit files that systemd knows about, you can just look at the logs:

journalctl -u flowmojo.com.service [-f]

On systems that don't have systemd running the unit file you can lookup the executable:

journalctl _COMM=flowmojo.server [-f]
-- Logs begin at Fri 2018-04-13 22:45:05 PDT, end at Sat 2018-04-21 >
Apr 21 11:21:57 drone flowmojo.server[13878]: Running with environme>
Apr 21 11:21:57 drone flowmojo.server[13878]: Local config applied: >
Apr 21 11:21:57 drone flowmojo.server[13878]: Local config applied: >
Apr 21 11:21:57 drone flowmojo.server[13878]: Local config applied: >
Apr 21 11:21:57 drone flowmojo.server[13878]: External services regi>
Apr 21 11:21:57 drone flowmojo.server[13878]: INSIDE ConsentApp

You can also pipe to jq for maximum JS geekiness. Reshaping your logs in to whatever you want.

journalctl -u flowmojo.com.service -f -o json-pretty | jq '{message: .MESSAGE, exe: ._COMM, service:.SERVICE, err: .ERR}'
{
  "message": "127.0.0.1 - - [22/Apr/2018:13:59:11 -0700] \"GET /api/v1/processes HTTP/1.0\" 200 321",
  "exe": "flowmojo.server",
  "service": "gorilla",
  "err": null
}
{
  "message": "127.0.0.1 - - [22/Apr/2018:13:59:11 -0700] \"GET /api/v1/instances HTTP/1.0\" 200 1644",
  "exe": "flowmojo.server",
  "service": "gorilla",
  "err": null
}