From: Lennart Poettering Date: Thu, 5 Jan 2012 22:54:45 +0000 (+0100) Subject: journal: introduce log target 'journal' for executed processes X-Git-Tag: v38~34 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=706343f492725fe430879c5d4a3485d7c49b0601;p=systemd journal: introduce log target 'journal' for executed processes --- diff --git a/man/systemd.conf.xml b/man/systemd.conf.xml index 56490ef4..ba144da8 100644 --- a/man/systemd.conf.xml +++ b/man/systemd.conf.xml @@ -81,7 +81,7 @@ ShowStatus=yes SysVConsole=yes CrashChVT=1 - DefaultStandardOutput=null + DefaultStandardOutput=journal DefaultStandardError=inherit Configures various diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 230c4a31..c1ab6b90 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -366,8 +366,10 @@ , , , + , + , , - or + or . If set to the file descriptor of standard input is @@ -392,8 +394,17 @@ service. connects it with the kernel log buffer which is accessible via - dmesg1. - and work + dmesg1. + connects it with the journal which is + accessible via + systemd-journalctl1 + (Note that everything that is written + to syslog or kmsg is implicitly stored + in the journal as well, those options + are hence supersets of this + one). , + and + work similarly but copy the output to the system console as well. connects @@ -407,7 +418,7 @@ in systemd.conf5, which defaults to - . + . StandardError= diff --git a/src/execute.c b/src/execute.c index a3573325..cacc8a73 100644 --- a/src/execute.c +++ b/src/execute.c @@ -211,7 +211,7 @@ static int connect_logger_as(const ExecContext *context, ExecOutput output, cons !!context->syslog_level_prefix, output == EXEC_OUTPUT_SYSLOG || output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE, output == EXEC_OUTPUT_KMSG || output == EXEC_OUTPUT_KMSG_AND_CONSOLE, - output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || output == EXEC_OUTPUT_KMSG_AND_CONSOLE); + output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || output == EXEC_OUTPUT_KMSG_AND_CONSOLE || output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE); if (fd != nfd) { r = dup2(fd, nfd) < 0 ? -errno : nfd; @@ -351,6 +351,8 @@ static int setup_output(const ExecContext *context, int socket_fd, const char *i case EXEC_OUTPUT_SYSLOG_AND_CONSOLE: case EXEC_OUTPUT_KMSG: case EXEC_OUTPUT_KMSG_AND_CONSOLE: + case EXEC_OUTPUT_JOURNAL: + case EXEC_OUTPUT_JOURNAL_AND_CONSOLE: return connect_logger_as(context, o, ident, STDOUT_FILENO); case EXEC_OUTPUT_SOCKET: @@ -404,6 +406,8 @@ static int setup_error(const ExecContext *context, int socket_fd, const char *id case EXEC_OUTPUT_SYSLOG_AND_CONSOLE: case EXEC_OUTPUT_KMSG: case EXEC_OUTPUT_KMSG_AND_CONSOLE: + case EXEC_OUTPUT_JOURNAL: + case EXEC_OUTPUT_JOURNAL_AND_CONSOLE: return connect_logger_as(context, e, ident, STDERR_FILENO); case EXEC_OUTPUT_SOCKET: @@ -1749,10 +1753,10 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { prefix, yes_no(c->tty_vhangup), prefix, yes_no(c->tty_vt_disallocate)); - if (c->std_output == EXEC_OUTPUT_SYSLOG || c->std_output == EXEC_OUTPUT_KMSG || - c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE || - c->std_error == EXEC_OUTPUT_SYSLOG || c->std_error == EXEC_OUTPUT_KMSG || - c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE) + if (c->std_output == EXEC_OUTPUT_SYSLOG || c->std_output == EXEC_OUTPUT_KMSG || c->std_output == EXEC_OUTPUT_JOURNAL || + c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE || + c->std_error == EXEC_OUTPUT_SYSLOG || c->std_error == EXEC_OUTPUT_KMSG || c->std_error == EXEC_OUTPUT_JOURNAL || + c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_JOURNAL_AND_CONSOLE) fprintf(f, "%sSyslogFacility: %s\n" "%sSyslogLevel: %s\n", @@ -2036,6 +2040,8 @@ static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = { [EXEC_OUTPUT_SYSLOG_AND_CONSOLE] = "syslog+console", [EXEC_OUTPUT_KMSG] = "kmsg", [EXEC_OUTPUT_KMSG_AND_CONSOLE] = "kmsg+console", + [EXEC_OUTPUT_JOURNAL] = "journal", + [EXEC_OUTPUT_JOURNAL_AND_CONSOLE] = "journal+console", [EXEC_OUTPUT_SOCKET] = "socket" }; diff --git a/src/execute.h b/src/execute.h index 4f05c9fa..187e8d22 100644 --- a/src/execute.h +++ b/src/execute.h @@ -74,6 +74,8 @@ typedef enum ExecOutput { EXEC_OUTPUT_SYSLOG_AND_CONSOLE, EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE, + EXEC_OUTPUT_JOURNAL, + EXEC_OUTPUT_JOURNAL_AND_CONSOLE, EXEC_OUTPUT_SOCKET, _EXEC_OUTPUT_MAX, _EXEC_OUTPUT_INVALID = -1 diff --git a/src/main.c b/src/main.c index 5c28a6c1..575e5ea3 100644 --- a/src/main.c +++ b/src/main.c @@ -77,7 +77,7 @@ static bool arg_mount_auto = true; static bool arg_swap_auto = true; static char **arg_default_controllers = NULL; static char ***arg_join_controllers = NULL; -static ExecOutput arg_default_std_output = EXEC_OUTPUT_SYSLOG; +static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL; static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT; static FILE* serialization = NULL; @@ -348,9 +348,9 @@ static int parse_proc_cmdline_word(const char *word) { "systemd.log_level=LEVEL Log level\n" "systemd.log_color=0|1 Highlight important log messages\n" "systemd.log_location=0|1 Include code location in log messages\n" - "systemd.default_standard_output=null|tty|syslog|syslog+console|kmsg|kmsg+console\n" + "systemd.default_standard_output=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n" " Set default log output for services\n" - "systemd.default_standard_error=null|tty|syslog|syslog+console|kmsg|kmsg+console\n" + "systemd.default_standard_error=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n" " Set default log error output for services\n"); } else if (streq(word, "quiet")) { diff --git a/src/service.c b/src/service.c index feecbbe2..b97114c4 100644 --- a/src/service.c +++ b/src/service.c @@ -841,7 +841,7 @@ static int service_load_sysv_path(Service *s, const char *path) { s->restart = SERVICE_RESTART_NO; if (s->meta.manager->sysv_console) - s->exec_context.std_output = EXEC_OUTPUT_SYSLOG_AND_CONSOLE; + s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE; s->exec_context.kill_mode = KILL_PROCESS; diff --git a/src/system.conf b/src/system.conf index 4e050579..2d1dd866 100644 --- a/src/system.conf +++ b/src/system.conf @@ -21,6 +21,6 @@ #MountAuto=yes #SwapAuto=yes #DefaultControllers=cpu -#DefaultStandardOutput=syslog +#DefaultStandardOutput=journal #DefaultStandardError=inherit #JoinControllers=cpu,cpuacct diff --git a/src/unit.c b/src/unit.c index b31b92fc..8630c3c5 100644 --- a/src/unit.c +++ b/src/unit.c @@ -561,11 +561,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { if (c->std_output != EXEC_OUTPUT_KMSG && c->std_output != EXEC_OUTPUT_SYSLOG && + c->std_output != EXEC_OUTPUT_JOURNAL && c->std_output != EXEC_OUTPUT_KMSG_AND_CONSOLE && c->std_output != EXEC_OUTPUT_SYSLOG_AND_CONSOLE && + c->std_output != EXEC_OUTPUT_JOURNAL_AND_CONSOLE && c->std_error != EXEC_OUTPUT_KMSG && c->std_error != EXEC_OUTPUT_SYSLOG && + c->std_error != EXEC_OUTPUT_JOURNAL && c->std_error != EXEC_OUTPUT_KMSG_AND_CONSOLE && + c->std_error != EXEC_OUTPUT_JOURNAL_AND_CONSOLE && c->std_error != EXEC_OUTPUT_SYSLOG_AND_CONSOLE) return 0;