5

If I query for raspotify service status, I see several of the latest entries of what looks like a log record that the service must keep somewhere:

● raspotify.service - Raspotify
   Loaded: loaded (/lib/systemd/system/raspotify.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-10-15 21:25:59 UTC; 14h ago
  Process: 19123 ExecStartPre=/bin/chown raspotify:raspotify /var/cache/raspotify (code=exited, status=0/SUCCESS)
  Process: 19120 ExecStartPre=/bin/mkdir -m 0755 -p /var/cache/raspotify (code=exited, status=0/SUCCESS)
 Main PID: 19125 (librespot)
   CGroup: /system.slice/raspotify.service
           └─19125 /usr/bin/librespot --name Peace Of Pi --backend alsa --bitrate 320 --disable-audio-cache --enable-volume-normalisation --linear-volume --initi

Oct 15 23:15:35 raspberrypi librespot[19125]: INFO:librespot::player_event_handler: Running ["/raspotify/onevent.sh"] with environment variables {"TRACK_ID": "7d    
Oct 15 23:15:35 raspberrypi librespot[19125]: Player event: change        
Oct 15 23:21:17 raspberrypi librespot[19125]: INFO:librespot_playback::player: Loading track "Charlie Brown Theme" with Spotify URI "spotify:track:1WdgaRSMceBEnh    
Oct 15 23:21:19 raspberrypi librespot[19125]: INFO:librespot_playback::player: Track "Charlie Brown Theme" loaded  
Oct 15 23:21:19 raspberrypi librespot[19125]: INFO:librespot::player_event_handler: Running ["/raspotify/onevent.sh"] with environment variables {"TRACK_ID": "3f    
Oct 15 23:21:19 raspberrypi librespot[19125]: Player event: change    
Oct 15 23:24:42 raspberrypi librespot[19125]: INFO:librespot::player_event_handler: Running ["/raspotify/onevent.sh"] with environment variables {"PLAYER_EVENT":    
Oct 15 23:24:42 raspberrypi librespot[19125]: Player event: stop    
Oct 16 09:53:04 raspberrypi librespot[19125]: INFO:librespot::player_event_handler: Running ["/raspotify/onevent.sh"] with environment variables {"PLAYER_EVENT":    
Oct 16 09:53:04 raspberrypi librespot[19125]: Player event: stop

Where does this stuff come from? Is it what the service outputs to some output stream and gets captured by the system service management software? Sorry, I'm quite green when it comes to Unix, just trying to build something useful. I'm on a light version of Raspbian.

1 Answer 1

6

The current Raspbian (Stretch) uses the systemd service. Its systemlogs are written by systemd-journald.service. Besides the excerpt that the query for raspotify service status provides you can check the full log using journalctl. From man systemd-journald.service:

systemd-journald is a system service that collects and stores logging data. It creates and maintains structured, indexed journals based on logging information that is received from a variety of sources:

  • Kernel log messages, via kmsg

  • Simple system log messages, via the libc syslog(3) call

  • Structured system log messages via the native Journal API, see sd_journal_print(4)

  • Standard output and standard error of service units. For further details see below.

  • Audit records, originating from the kernel audit subsystem

librespot that is the underlying library used by raspotify uses Rust's env_logger::LogBuilder. env_logger prints to stderr by default - which might very well be the way the logs find to systemd-journald. The logs are usually stored in /var/log/journal/ but since you would usually use journalctl to querry it, it does not matter where it is...

1
  • 1
    Worked like a charm, thanks: journalctl --system _SYSTEMD_UNIT=raspotify.service I could probably also install some beats service from Elastick stack and export these stats to have some sweet Kibana visualizations :) Commented Oct 17, 2018 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.