bool d_ringsRecordResponses{true};
bool d_snmpEnabled{false};
bool d_snmpTrapsEnabled{false};
- bool d_structuredLogging{false};
+ bool d_structuredLogging{true};
bool d_structuredLoggingUseServerID{false};
};
parameters:
- name: "enabled"
type: "bool"
- default: "false"
+ default: "true"
description: |
Set whether log messages should be in structured-logging format."
changes:
bool checkConfig{false};
bool beClient{false};
bool beSupervised{false};
- bool useStructuredLogging{false};
+ bool useStructuredLogging{true};
};
static void usage()
cout << "--disable-syslog Don't log to syslog, only to stdout\n";
cout << " (use with e.g. systemd)\n";
cout << "--log-timestamps Prepend timestamps to messages logged to stdout\n";
- cout << "--structured-logging Enable structured logging\n";
+ cout << "--structured-logging true|false Whether to enable structured logging\n";
cout << "--structured-logging-backend BACKEND The backend to use when structured logging is enabled\n";
cout << " Supported values are 'default', 'json' and 'systemd-journal'\n";
cout << "-u,--uid uid Change the process user ID after binding sockets\n";
{"local", required_argument, nullptr, 'l'},
{"log-timestamps", no_argument, nullptr, 4},
{"setkey", required_argument, nullptr, 'k'},
- {"structured-logging", no_argument, nullptr, 's'},
+ {"structured-logging", required_argument, nullptr, 's'},
{"structured-logging-backend", required_argument, nullptr, 5},
{"supervised", no_argument, nullptr, 3},
{"uid", required_argument, nullptr, 'u'},
cmdLine.locals.push_back(boost::trim_copy(string(optarg)));
break;
case 's':
- cmdLine.useStructuredLogging = true;
+ cmdLine.useStructuredLogging = (boost::to_lower_copy(std::string(optarg)) == "true");
break;
case 'u':
cmdLine.uid = optarg;
--disable-syslog Disable logging to syslog. Use this when running inside a supervisor
that handles logging (like systemd).
--log-timestamps Prepend timestamps to messages logged to standard out.
---structured-logging Enable structured logging.
+--structured-logging <true|false> Whether to enable structured logging.
--structured-logging-backend <backend> The backend to use when structured logging is enabled.
Supported values are 'default', 'json' and 'systemd-journal'.
-u, --uid <uid> Change the process user to *uid* after binding sockets. *uid* can be
The ``backend`` option has been added.
The ``setInstanceFromServerID`` option has been added
The ``levelPrefix`` option has no longer any effect because it was confusing. The log level is now always logged as ``level`` and the syslog priority, if any, as ``priority`` in all backends except the default one where it is named ``prio``
+ Structured logging is now enabled by default.
- Set whether log messages should be in structured-logging format. This is turned off by default. See :doc:`../advanced/structured-logging-dictionary` for more details.
+ Set whether log messages should be in structured-logging format. This is enabled by default since 2.1.0. See :doc:`../advanced/structured-logging-dictionary` for more details.
The resulting format looks like this (when timestamps are enabled via ``--log-timestamps`` and ``timeFormat="ISO8601"``)::
_UDPResponder = None
_TCPResponder = None
_extraStartupSleep = 0
+ _disableStructuredLoggingOnCL = False
_dnsDistPort = pickAvailablePort()
_consolePort = pickAvailablePort()
_testServerPort = pickAvailablePort()
if cls._verboseMode:
dnsdistcmd.append('-v')
+
+ if cls._disableStructuredLoggingOnCL:
+ dnsdistcmd.append('--structured-logging')
+ dnsdistcmd.append('false')
+
if cls._sudoMode:
preserve_env_values = ['LD_LIBRARY_PATH', 'LLVM_PROFILE_FILE']
for value in preserve_env_values:
else:
if cls._checkConfigExpectedOutput is not None:
expectedOutput = cls._checkConfigExpectedOutput
- else:
- expectedOutput = ('Configuration \'%s\' OK!\n' % (confFile)).encode()
-
- if not cls._verboseMode and output != expectedOutput:
- raise AssertionError('dnsdist --check-config failed: %s (expected %s)' % (output, expectedOutput))
+ if not cls._verboseMode and output != expectedOutput:
+ raise AssertionError('dnsdist --check-config failed: %s (expected %s)' % (output, expectedOutput))
+ elif not cls._verboseMode:
+ if not cls._disableStructuredLoggingOnCL:
+ expectedPrefix = b'msg="Configuration OK" subsystem="setup" level="0" prio="Info" ts="'
+ if not output.startswith(expectedPrefix):
+ raise AssertionError('dnsdist --check-config failed: %s (expected prefix %s)' % (output, expectedPrefix))
+ else:
+ expectedOutput = ('Configuration \'%s\' OK!\n' % (confFile)).encode()
+ if output != expectedOutput:
+ raise AssertionError('dnsdist --check-config failed: %s (expected %s)' % (output, expectedOutput))
logFile = os.path.join('configs', 'dnsdist_%s.log' % (cls.__name__))
with open(logFile, 'w') as fdLog:
class TestConfigurationUpdates(DNSDistTest):
_yaml_config_template = """---
+logging:
+ structured:
+ enabled: false
+
console:
listen_address: "127.0.0.1:%d"
key: "%s"
class TestDOHOverHTTPNGHTTP2(DOHOverHTTP, DNSDistDOHTest):
_dohLibrary = 'nghttp2'
- _checkConfigExpectedOutput = b"""No certificate provided for DoH endpoint 127.0.0.1:%d, running in DNS over HTTP mode instead of DNS over HTTPS
-Configuration 'configs/dnsdist_TestDOHOverHTTPNGHTTP2.conf' OK!
-""" % (DOHOverHTTP._dohServerPort)
+ _checkConfigExpectedOutputPrefix = b'msg="No certificate provided for DoH frontend, running in DNS over HTTP mode instead of DNS over HTTPS"'
class DOHWithCache(object):
class IncomingProtocolYAMLConfig(DNSDistTest, IncomingProtocol):
_yaml_config_template = """
+logging:
+ structured:
+ enabled: false
backends:
- address: "127.0.0.1:%d"
protocol: Do53
class TestLuaFrontendBindings(DNSDistTest):
_config_template = """
+ setStructuredLogging(false)
newServer{address="127.0.0.1:%d"}
-- check that all these methods return nil on a non-existing entry
class TestYamlUnknownSelectorName(DNSDistTest):
_yaml_config_template = """---
+logging:
+ structured:
+ enabled: false
+
binds:
- listen_address: "127.0.0.1:%d"
protocol: Do53
"""
_yaml_config_params = ['_dnsDistPort', '_testServerPort']
_config_params = []
+ # we need this because the error is triggered during the parsing of the YAML configuration,
+ # too early for the logging for the logging configuration to have been applied
+ _disableStructuredLoggingOnCL = True
def testFailToStart(self):
"""
class TestYamlUnknownPolicyName(DNSDistTest):
_yaml_config_template = """---
+logging:
+ structured:
+ enabled: false
+
binds:
- listen_address: "127.0.0.1:%d"
protocol: Do53