Search code examples
linuxdhcp

Pushing kea-dhcp4 server logs to different files based on severity


Unable to isolate kea logs based on severity level.

 "Logging": {
    "loggers": [
      {
        "name": "kea-dhcp4",
        "output_options": [
          {
            "output": "/var/log/kea-dhcp4.log"
          }
        ],
        "severity": "WARN"
      },
      {
        "debuglevel": 99,
        "name": "kea-dhcp4",
        "output_options": [
          {
            "output": "/var/log/kea-debug.log"
          }
        ],
        "severity": "DEBUG"
      }
    ]
  }

Above is the portion of kea server config, all the logs are directed to "/var/log/kea-debug.log" irrespective of severity level. Expected: logs of severity "WARN" and higher to be logged to "/var/log/kea-dhcp4.log".


Solution

  • From a quick reading of Section 18 of https://jenkins.isc.org/job/Kea_doc/guide/kea-guide.html, I would:

    • Try to put the debug log section before the warn log section to see if only warnings get logged.
    • Check the keactrl configuration.

    It would appear that you can only have one log per "name" and that if you want debug logging, you would have to use a different logger name, eg. "kea-ctrl-agent" instead of "kea-dhcp4" - but it's unclear if there's a hierarchy involved and if that will catch entries of parts below it.

    It should be easy to fix for the developers if it is the case - you should update the bug report in the kea project, here: https://gitlab.isc.org/isc-projects/kea/issues/592

    Some other things that you could do is to log everything to syslog, and send it to a remote log and use something like splunk or logzilla to sort them by severity.

    Or you if it's just temporarily, you could create a cron job that does this every few minutes, or just run it on a tail:

    tail /var/log/kea-debug.log|egrep '(WARN|ERR|FATAL)' /var/log/kea-debug.log|tee -a /var/log/kea-dhcp.log
    

    Assuming those words are present in the debug log, when those severities pop up.