diff --git a/doc/chronyd.adoc b/doc/chronyd.adoc index 2ae5b17..68f8782 100644 --- a/doc/chronyd.adoc +++ b/doc/chronyd.adoc @@ -66,6 +66,10 @@ and all messages will be sent to the terminal instead of to syslog. When *chronyd* was compiled with debugging support, this option can be used twice to print also debugging messages. +*-l* _file_:: +This option specifies a file which should be used for logging instead of syslog +or terminal. + *-q*:: When run in this mode, *chronyd* will set the system clock once and exit. It will not detach from the terminal. diff --git a/main.c b/main.c index 29bc6be..dd07019 100644 --- a/main.c +++ b/main.c @@ -370,7 +370,7 @@ int main { const char *conf_file = DEFAULT_CONF_FILE; const char *progname = argv[0]; - char *user = NULL; + char *user = NULL, *log_file = NULL; struct passwd *pw; int debug = 0, nofork = 0, address_family = IPADDR_UNSPEC; int do_init_rtc = 0, restarted = 0, timeout = 0; @@ -417,6 +417,9 @@ int main /* This write to the terminal is OK, it comes before we turn into a daemon */ printf("chronyd (chrony) version %s (%s)\n", CHRONY_VERSION, CHRONYD_FEATURES); return 0; + } else if (!strcmp("-l", *argv)) { + ++argv, --argc; + log_file = *argv; } else if (!strcmp("-n", *argv)) { nofork = 1; } else if (!strcmp("-d", *argv)) { @@ -463,7 +466,9 @@ int main go_daemon(); } - if (system_log) { + if (log_file) { + LOG_OpenFileLog(log_file); + } else if (system_log) { LOG_OpenSystemLog(); }