diff --git a/janus.c b/janus.c index 77965af98c8..149585fb5c1 100644 --- a/janus.c +++ b/janus.c @@ -4119,7 +4119,7 @@ gint main(int argc, char *argv[]) if(args_info.disable_stdout_given) { use_stdout = FALSE; janus_config_add(config, config_general, janus_config_item_create("log_to_stdout", "no")); - } else { + } else if(!args_info.log_stdout_given) { /* Check if the configuration file is saying anything about this */ janus_config_item *item = janus_config_get(config, config_general, janus_config_type_item, "log_to_stdout"); if(item && item->value && !janus_is_true(item->value)) @@ -4147,13 +4147,9 @@ gint main(int argc, char *argv[]) daemonize = TRUE; } /* If we're going to daemonize, make sure logging to stdout is disabled and a log file has been specified */ - if(daemonize && use_stdout) { + if(daemonize && use_stdout && !args_info.log_stdout_given) { use_stdout = FALSE; } - if(daemonize && logfile == NULL) { - g_print("Running Janus as a daemon but no log file provided, giving up...\n"); - exit(1); - } /* Daemonize now, if we need to */ if(daemonize) { g_print("Running Janus as a daemon\n"); diff --git a/janus.ggo b/janus.ggo index fa8b157b6ca..8802b1a2ef7 100644 --- a/janus.ggo +++ b/janus.ggo @@ -2,6 +2,7 @@ option "daemon" b "Launch Janus in background as a daemon" flag off option "pid-file" p "Open the specified PID file when starting Janus (default=none)" string typestr="path" optional option "disable-stdout" N "Disable stdout based logging" flag off +option "log-stdout" - "Log to stdout" flag off option "log-file" L "Log to the specified file (default=stdout only)" string typestr="path" optional option "cwd-path" H "Working directory for Janus daemon process (default=/)" string typestr="path" optional option "interface" i "Interface to use (will be the public IP)" string typestr="ipaddress" optional diff --git a/log.c b/log.c index e1934bb781b..f9003cb90b8 100644 --- a/log.c +++ b/log.c @@ -239,7 +239,7 @@ int janus_log_init(gboolean daemon, gboolean console, const char *logfile) { g_print("WARNING: logging completely disabled!\n"); g_print(" (no stdout and no logfile, this may not be what you want...)\n"); } - if(daemon) { + if(daemon && !console) { /* Replace the standard file descriptors */ if (freopen("/dev/null", "r", stdin) == NULL) { g_print("Error replacing stdin with /dev/null\n");