To both test for NOTIFY_SOCKET (to see if we're runnign underst systemd)
and availbility of the journal socket (to see if systemd-journal is
active)
#ifdef HAVE_SYSTEMD
if (getenv("NOTIFY_SOCKET") != nullptr) {
- g_slog = Logging::Logger::create(loggerSDBackend);
+ if (int fd = sd_journal_stream_fd("pdns-recusor", LOG_DEBUG, 0); fd >= 0) {
+ g_slog = Logging::Logger::create(loggerSDBackend);
+ close(fd);
+ }
}
- else
#endif
- {
+ if (g_slog == nullptr) {
g_slog = Logging::Logger::create(loggerBackend);
}
// Missing: a mechanism to call setVerbosity(x)