#include "macro.h"
#include "mkdir-label.h"
#include "path-util.h"
+#include "process-util.h"
#include "special.h"
#include "specifier.h"
#include "string-util.h"
}
void log_setup_generator(void) {
- /* Disable talking to syslog/journal (i.e. the two IPC-based loggers) if we run in system context. */
- if (cg_pid_get_owner_uid(0, NULL) == -ENXIO /* not running in a per-user slice */)
- log_set_prohibit_ipc(true);
+ if (invoked_by_systemd()) {
+ /* Disable talking to syslog/journal (i.e. the two IPC-based loggers) if we run in system context. */
+ if (cg_pid_get_owner_uid(0, NULL) == -ENXIO /* not running in a per-user slice */)
+ log_set_prohibit_ipc(true);
+
+ /* This effectively means: journal for per-user generators, kmsg otherwise */
+ log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
+ }
- log_set_target(LOG_TARGET_JOURNAL_OR_KMSG); /* This effectively means: journal for per-user generators, kmsg otherwise */
log_parse_environment();
(void) log_open();
}