diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 5c8d11692d075f75f95fe1790fe945a859a5e7d9..8e3701c17d7e16c09fcf4d4d8509b67ade6dc978 100755
--- a/daemons/ganeti-masterd
+++ b/daemons/ganeti-masterd
@@ -391,7 +391,8 @@ def main():
     utils.Daemonize(logfile=constants.LOG_MASTERDAEMON,
                     noclose_fds=[master.fileno()])
 
-  logger.SetupDaemon(constants.LOG_MASTERDAEMON, debug=options.debug)
+  logger.SetupDaemon(constants.LOG_MASTERDAEMON, debug=options.debug,
+                     stderr_logging=not options.fork)
 
   logging.info("ganeti master daemon startup")
 
diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index b5d1984161dfc5d0237004e84e730dfc48093027..cb72b4cf3531ecaa3fba4adc3f9dfbe6bba90ad3 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -633,7 +633,8 @@ def main():
   if options.fork:
     utils.Daemonize(logfile=constants.LOG_NODESERVER)
 
-  logger.SetupDaemon(logfile=constants.LOG_NODESERVER, debug=options.debug)
+  logger.SetupDaemon(logfile=constants.LOG_NODESERVER, debug=options.debug,
+                     stderr_logging=not options.fork)
   logging.info("ganeti node daemon startup")
 
   global _EXIT_GANETI_NODED
diff --git a/lib/logger.py b/lib/logger.py
index f92dbaa7fb4dbdc5c79d672d1734cc67b6e8cf55..37573ee472baf9f3d10028d6bb2b7706d9b347ee 100644
--- a/lib/logger.py
+++ b/lib/logger.py
@@ -84,12 +84,12 @@ def SetupLogging(program='ganeti', debug=False):
   root_logger.addHandler(stderr_file)
 
 
-def SetupDaemon(logfile, debug=False):
+def SetupDaemon(logfile, debug=False, stderr_logging=False):
   """Configures the logging module for daemons
 
   """
   if debug:
-    fmt = "%(asctime)s: %(levelname)s %(pathname)s:%(lineno)s %(message)s"
+    fmt = "%(asctime)s: %(levelname)s %(module)s:%(lineno)s %(message)s"
   else:
     fmt = "%(asctime)s: %(levelname)s %(message)s"
   formatter = logging.Formatter(fmt)
@@ -109,7 +109,8 @@ def SetupDaemon(logfile, debug=False):
   root_logger = logging.getLogger("")
   root_logger.setLevel(logging.NOTSET)
   root_logger.addHandler(logfile_handler)
-  root_logger.addHandler(stderr_handler)
+  if stderr_logging:
+    root_logger.addHandler(stderr_handler)
 
 
 # Backwards compatibility