[Kea-users] kea-dhcp-ddns.conf log output format and %m

Francis Dupont fdupont at isc.org
Sun Aug 2 16:56:15 UTC 2020


Rick Dicaire writes:
> Hi, new to list and kea, using 1.6 from ISC's cloudsmith.io deb repo on
> Ubuntu 18.04 LTS.
> I have a working dhcp4 and ddns configuration.
> I'm now trying to customize logging to output json for easy ingestion by
> ELK stack. I'm working with dhcp-ddns first.
> I'm using this pattern:

=> the pattern is given to log4cplus with as reference:
https://log4cplus.sourceforge.io/docs/html/classlog4cplus_1_1PatternLayout.html

> "pattern":
> "{\"date\":\"%D{%Y-%m-%dT%H:%M:%S.%q%z}\",\"kea.ddns.log.level\":
> \"%p\",\"kea.ddns.log.component\":\"%c\",\"kea.ddns.log.pid\":\"%i\",\"kea.dd
> ns.log.data\":
> \"%m\"}\n"

=> hum, you assume here that anything in between two (escaped) quotes makes
a valid JSON string. Of course this is not true (reference here is ECMA 404)
and the multi-line issue is only one of the possible problems.

> As I understand json, multiline is not valid so I'm trying to figure out if
> the format of %m can be modified to output as single line?

=> log4cplus offers some formating but only a subset of printf so
nothing powerful enough. I am afraid you have to do the to JSON translation
on the other side i.e. in log files or (new)syslog.
 BTW there are already a lot of log filters so if you find a suitable one
please share here. I know for instance that Jenkins has a log file to XML
filter tool...
 I am looking for direct solution in log4j (log4cplus was designed from this).
There are some ideas using %m but we know it is not enough. Some suggest
to write a JSON Appender, can be done with not trivial coding...
(reference https://github.com/michaeltandy/log4j-json, I found more but
for log4j2).
 I can see 3 problems to do this in Kea:
 - there is no hook in Kea for logging i.e. no easy place to insert code
 - the JSON code is in another and later library (backward dependency)
 - it requires significant manpower to develop.

Regards

Francis Dupont <fdupont at isc.org>


More information about the Kea-users mailing list