diff --git a/src/basic/log.c b/src/basic/log.c index 9169474289..8a65aa349e 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1314,6 +1314,14 @@ int log_syntax_invalid_utf8_internal( void log_set_upgrade_syslog_to_journal(bool b) { upgrade_syslog_to_journal = b; + + /* Make the change effective immediately */ + if (b) { + if (log_target == LOG_TARGET_SYSLOG) + log_target = LOG_TARGET_JOURNAL; + else if (log_target == LOG_TARGET_SYSLOG_OR_KMSG) + log_target = LOG_TARGET_JOURNAL_OR_KMSG; + } } void log_set_always_reopen_console(bool b) { diff --git a/src/basic/log.h b/src/basic/log.h index b97cdcd703..910a89a255 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -302,6 +302,7 @@ LogTarget log_target_from_string(const char *s) _pure_; void log_received_signal(int level, const struct signalfd_siginfo *si); +/* If turned on, any requests for a log target involving "syslog" will be implicitly upgraded to the equivalent journal target */ void log_set_upgrade_syslog_to_journal(bool b); void log_set_always_reopen_console(bool b); void log_set_open_when_needed(bool b); diff --git a/src/core/main.c b/src/core/main.c index 7d20f4e67b..9ecb8e9835 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2328,6 +2328,7 @@ int main(int argc, char *argv[]) { saved_argv = argv; saved_argc = argc; + /* Make sure that if the user says "syslog" we actually log to the journal. */ log_set_upgrade_syslog_to_journal(true); if (getpid_cached() == 1) {