diff --git a/docs/manpages/ixfrdist.yml.5.rst b/docs/manpages/ixfrdist.yml.5.rst index 6ad3fd132f80..6e9ffd0f2e7d 100644 --- a/docs/manpages/ixfrdist.yml.5.rst +++ b/docs/manpages/ixfrdist.yml.5.rst @@ -108,6 +108,14 @@ Options Entries without a netmask will be interpreted as a single address. By default, this list is set to ``127.0.0.0/8`` and ``::1/128``. +:webserver-loglevel: + How much the webserver should log: 'none', 'normal' or 'detailed'. + When logging, each log-line contains the UUID of the request, this allows finding errors caused by certain requests. + With 'none', nothing is logged except for errors. + With 'normal' (the default), one line per request is logged in the style of the common log format:: + [NOTICE] [webserver] 46326eef-b3ba-4455-8e76-15ec73879aa3 127.0.0.1:57566 "GET /metrics HTTP/1.1" 200 1846 + with 'detailed', the full requests and responses (including headers) are logged along with the regular log-line from 'normal'. + See also -------- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index a2870326a3ad..e72a34db4f33 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -640,8 +640,8 @@ ixfrdist_SOURCES = \ statbag.cc \ threadname.hh threadname.cc \ tsigverifier.cc tsigverifier.hh \ - uuid-utils.hh uuid-utils.cc \ unix_utility.cc \ + uuid-utils.hh uuid-utils.cc \ webserver.hh webserver.cc \ zoneparser-tng.cc diff --git a/pdns/ixfrdist-web.cc b/pdns/ixfrdist-web.cc index 01d2505d8ffd..485e720bcd8d 100644 --- a/pdns/ixfrdist-web.cc +++ b/pdns/ixfrdist-web.cc @@ -27,10 +27,11 @@ string doGetStats(); -IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl) : +IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl, const string &loglevel) : d_ws(std::unique_ptr(new WebServer(listenAddress.toString(), listenAddress.getPort()))) { d_ws->setACL(acl); + d_ws->setLogLevel(loglevel); d_ws->registerWebHandler("/metrics", boost::bind(&IXFRDistWebServer::getMetrics, this, _1, _2)); d_ws->bind(); } diff --git a/pdns/ixfrdist-web.hh b/pdns/ixfrdist-web.hh index 580e97634433..e1c1734cc39b 100644 --- a/pdns/ixfrdist-web.hh +++ b/pdns/ixfrdist-web.hh @@ -26,7 +26,7 @@ class IXFRDistWebServer { public: - explicit IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl); + explicit IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl, const string &loglevel); void go(); private: diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 1ba8ffed0c02..5331d172d125 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -1125,6 +1125,16 @@ static bool parseAndCheckConfig(const string& configpath, YAML::Node& config) { } } + if (config["webserver-loglevel"]) { + try { + config["webserver-loglevel"].as(); + } + catch (const runtime_error &e) { + g_log<(); + } + // Launch the webserver! - std::thread(&IXFRDistWebServer::go, IXFRDistWebServer(config["webserver-address"].as(), wsACL)).detach(); + try { + std::thread(&IXFRDistWebServer::go, IXFRDistWebServer(config["webserver-address"].as(), wsACL, loglevel)).detach(); + } catch (const PDNSException &e) { + g_log<