diff --git a/NEWS b/NEWS index a8bacdbc2..6628488ae 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ver 0.21.3 (not yet released) * output - alsa: fix crash bug - alsa: fix stuttering at start of playback +* log: default to journal if MPD was started as systemd service ver 0.21.2 (2018/11/12) * protocol diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 6b2a74c9e..46d2ef62a 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -30,6 +30,10 @@ #include "util/RuntimeError.hxx" #include "system/Error.hxx" +#ifdef ENABLE_SYSTEMD_DAEMON +#include +#endif + #include #include #include @@ -139,6 +143,16 @@ log_init(const ConfigData &config, bool verbose, bool use_stdout) if (param == nullptr) { /* no configuration: default to syslog (if available) */ +#ifdef ENABLE_SYSTEMD_DAEMON + if (sd_booted() && + getenv("NOTIFY_SOCKET") != nullptr) { + /* if MPD was started as a systemd + service, default to journal (which + is connected to fd=2) */ + out_fd = STDOUT_FILENO; + return; + } +#endif #ifndef HAVE_SYSLOG throw std::runtime_error("config parameter 'log_file' not found"); #endif