]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add a disable-syslog setting
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 15 Mar 2016 10:51:43 +0000 (11:51 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 15 Mar 2016 12:11:03 +0000 (13:11 +0100)
This allows the use of e.g. the `Type=simple` in systemd and prevents
the double logging issue.

docs/markdown/authoritative/settings.md
docs/markdown/recursor/settings.md
pdns/common_startup.cc
pdns/logger.cc
pdns/logger.hh
pdns/pdns.conf-dist
pdns/pdns_recursor.cc
pdns/receiver.cc

index 2cdd7e53861a9ea870e8dc3281bff4443c226072..a47a1a47c97046c64698326a082ad525633feda0 100644 (file)
@@ -259,6 +259,14 @@ Do not allow zone transfers.
 Disable the rectify step during an outgoing AXFR. Only required for regression
 testing.
 
+## `disable-syslog`
+* Boolean
+* Default: no
+
+Do not log to syslog, only to stdout. Use this setting when running inside a
+supervisor that handles logging (like systemd). **Note**: do not use this setting
+in combination with [`daemon`](#daemon) as all logging will disappear.
+
 ## `disable-tcp`
 * Boolean
 * Default: no
index 0b573a55fd2de74aeb94e3cab73433c6be32d9ad..e8cbd6f7af3007ac1907b57f5212fb7c0d33897f 100644 (file)
@@ -167,6 +167,14 @@ Which domains we only accept delegations from (a Verisign special).
 Turn off the packet cache. Useful when running with Lua scripts that can not be
 cached.
 
+## `disable-syslog`
+* Boolean
+* Default: no
+
+Do not log to syslog, only to stdout. Use this setting when running inside a
+supervisor that handles logging (like systemd). **Note**: do not use this setting
+in combination with [`daemon`](#daemon) as all logging will disappear.
+
 ## `dnssec`
 * One of `off`, `process`, `log-fail`, `validate`, String
 * Default: `off` (**note**: was `process` until 4.0.0-alpha2)
index fb4195418b941a277b621f461c0a823fe9862d60..237ee3cde657c6a8fb8d52c407735fc679c70867 100644 (file)
@@ -88,6 +88,7 @@ void declareArguments()
   ::arg().set("version-string","PowerDNS version in packets - full, anonymous, powerdns or custom")="full"; 
   ::arg().set("control-console","Debugging switch - don't use")="no"; // but I know you will!
   ::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="4";
+  ::arg().set("disable-syslog","Disable logging to syslog, useful when running inside a supervisor that logs stdout")="no";
   ::arg().set("default-soa-name","name to insert in the SOA record if none set in the backend")="a.misconfigured.powerdns.server";
   ::arg().set("default-soa-mail","mail address to insert in the SOA record if none set in the backend")="";
   ::arg().set("distributor-threads","Default number of Distributor (backend) threads to start")="3";
index d4fcdcd7a9767cbbceacbff7c73a6096c79585c5..a21000466847399b30752a0149287ba77bf0ada8 100644 (file)
@@ -56,7 +56,7 @@ void Logger::log(const string &msg, Urgency u)
     Lock l(&m); // the C++-2011 spec says we need this, and OSX actually does
     clog << string(buffer) + msg <<endl;
   }
-  if( u <= d_loglevel ) {
+  if( u <= d_loglevel && !d_disableSyslog ) {
 #ifndef RECURSOR
     S.ringAccount("logmessages",msg);
 #endif
index d4079f885af8abf8704b7744a29c4db24a9f9754..9d1d85d2cf6a823842fb9752c5427fde22e3a74b 100644 (file)
@@ -56,6 +56,10 @@ public:
   void toConsole(Urgency);
   void setLoglevel( Urgency );
 
+  void disableSyslog(bool d) {
+    d_disableSyslog = d;
+  }
+
   //! Log to a file.
   void toFile( const string & filename );
   
@@ -102,6 +106,7 @@ private:
   Urgency d_loglevel;
   Urgency consoleUrgency;
   bool opened;
+  bool d_disableSyslog;
   static pthread_once_t s_once;
   static pthread_key_t s_loggerKey;
 };
index 5d6528ffd9406ba6e94619f8bc6a780959ba6de3..ab402638af10a9ab5d7554a417d80e9cb18be2bf 100644 (file)
 #
 # disable-axfr-rectify=no
 
+#################################
+# disable-syslog       Disable logging to syslog, useful when running inside a supervisor that logs stdout
+#
+# disable-syslog=no
+
 #################################
 # disable-tcp  Do not listen to TCP queries
 #
index fd6e453ed0ebcc5f81b13dfd619f9b6760c1c6cd..f6c5174963a10bd7a6cd71c45425530e58457684 100644 (file)
@@ -2265,6 +2265,7 @@ int serviceMain(int argc, char*argv[])
 {
   L.setName(s_programname);
   L.setLoglevel((Logger::Urgency)(6)); // info and up
+  L.disableSyslog(::arg().mustDo("disable-syslog"));
 
   if(!::arg()["logging-facility"].empty()) {
     int val=logFacilityToLOG(::arg().asNum("logging-facility") );
@@ -2636,6 +2637,7 @@ int main(int argc, char **argv)
     ::arg().set("daemon","Operate as a daemon")="no";
     ::arg().setSwitch("write-pid","Write a PID file")="yes";
     ::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="4";
+    ::arg().set("disable-syslog","Disable logging to syslog, useful when running inside a supervisor that logs stdout")="no";
     ::arg().set("log-common-errors","If we should log rather common errors")="yes";
     ::arg().set("chroot","switch to chroot jail")="";
     ::arg().set("setgid","If set, change group id to this gid for more security")="";
index e98f3d82a9f428e2c068d48f4d053ff5912eaa94..6bc84997de6b0753f1bc13505af61082d1601082 100644 (file)
@@ -468,6 +468,7 @@ int main(int argc, char **argv)
     }
 
     L.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
+    L.disableSyslog(::arg().mustDo("disable-syslog"));
     L.toConsole((Logger::Urgency)(::arg().asNum("loglevel")));  
 
     if(::arg().mustDo("help") || ::arg().mustDo("config")) {