Permalink
Browse files

Add a disable-syslog setting

This allows the use of e.g. the `Type=simple` in systemd and prevents
the double logging issue.
  • Loading branch information...
1 parent 325a8e1 commit 280d6657a8d226a1043b7a4fc1613af0bb90a3ed @pieterlexis pieterlexis committed Mar 15, 2016
Showing with 15 additions and 1 deletion.
  1. +1 −0 pdns/common_startup.cc
  2. +1 −1 pdns/logger.cc
  3. +5 −0 pdns/logger.hh
  4. +5 −0 pdns/pdns.conf-dist
  5. +2 −0 pdns/pdns_recursor.cc
  6. +1 −0 pdns/receiver.cc
@@ -78,6 +78,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";
View
@@ -50,7 +50,7 @@ void Logger::log(const string &msg, Urgency u)
clog<<buffer;
clog <<msg <<endl;
}
- if( u <= d_loglevel ) {
+ if( u <= d_loglevel && !d_disableSyslog ) {
#ifndef RECURSOR
S.ringAccount("logmessages",msg);
#endif
View
@@ -58,6 +58,10 @@ public:
void toConsole(Urgency);
void setLoglevel( Urgency );
+ void disableSyslog(bool d) {
+ d_disableSyslog = d;
+ }
+
//! Log to a file.
void toFile( const string & filename );
@@ -91,6 +95,7 @@ private:
Urgency d_loglevel;
Urgency consoleUrgency;
pthread_mutex_t lock;
+ bool d_disableSyslog;
};
extern Logger &theL(const string &pname="");
View
@@ -135,6 +135,11 @@
# 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
#
# disable-tcp=no
@@ -1749,6 +1749,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") );
@@ -2086,6 +2087,7 @@ int main(int argc, char **argv)
::arg().set("trace","if we should output heaps of logging. set to 'fail' to only log failing domains")="off";
::arg().set("daemon","Operate as a daemon")="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")="";
View
@@ -450,6 +450,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")) {

0 comments on commit 280d665

Please sign in to comment.