Page 1 of 1

add new log Topic for Dhcp Script logging vs normal scripts logging

Posted: Fri Nov 20, 2020 9:39 pm
by jo2jo
Goal: Have an extra Log -> "Topics" tag added to dhcp-server run scripts. (ie like "dhcp" , so that we can distinguish them in /system logging action vs normal log entries from /sys script , scripts).

we have a script under /ip dhcp-server that makes a log of the "Active Host Name" of every dhcp-client (so that we retain this info in our remote logging system, as some customers want this data).

We also have several standard scripts ie /sys script with various :log info "xyz" entries for logging the status of when scripts are trigged by scheduler.

the issue is with a /system logging add action=scriptDiskLOG topics=script , our logs get filled up with all the /ip dhcp-server logs. (and there is no way to distinguish/sort them in /system logging action, as they both only have the log Topics of "script,info" - thus if you exclude one, you exclude both, in terms of /system logging action topics=script ).

(i hope im explaining this well, if not i can rephrase)

Re: add new log Topic for Dhcp Script logging vs normal scripts logging

Posted: Sat Nov 21, 2020 11:14 am
by sindy
For feature requests, the official channel is your distributor, or you can find a dedicated topic here on the forum, created by Mikrotik staff for feature requesting.

As a quick help, you can use /log warning (or /log error) rather than /log info in your DHCP script, and set /system logging add topics=script,warning action=scriptDiskLOG.

Since you seem to forward the data from the log file to the remote logging system by means of another script, rather than to use /system logging action add target=remote name=remote-log-server directly, you could also misuse e.g an address-list for the purpose of appending the information to a dedicated file:
/ip firewall address list add list=dhcp-lease address=some.ip.add.ress comment="the real info you want to log" timeout=10s
/ip firewall address-list print file=leaseLOG append where list=dhcp-lease
/ip firewall address-list remove [find list=dhcp-lease]

But it is 6 lines per lease.