With the current settings in 15-pihole-admin.conf the logfile looks like:
1676620203|172.26.0.1|pihole.xxxxx.nl|GET /admin/api.php?summaryRaw&getQuerySources&topClientsBlocked HTTP/1.1|200|1131
whereas errror-pihole.log looks like:
2023-02-17 20:09:28: server.c.1513) server started (lighttpd/1.4.59)
By a small change in 15-pihole-admin.conf I can get it to show:
[17/Feb/2023:20:17:19 +0100]|172.26.0.1|pihole.xxxxx.nl|GET /admin/api.php?getForwardDestinations HTTP/1.1|200|159
The change:
accesslog.format = "%t|%h|%V|%r|%s|%b"
where it was:
accesslog.format = "%(%s)t|%h|%V|%r|%s|%b"
Can this be changed (or maybe preferably the way it's formatted in error-pihole.log) ?
Just a background explanation for the different formats:
The Error log and Access log are handled by completely different lighttpd
modules.
- The
error-pihole.log
file uses the default format (and I don't think it is possible to change that).
- The default format for
accesslog
module uses a very different string where the timestamp is the 4th field (similar to the Apache log), but we never used that.
Pi-hole always (I think before 2017) used a format starting with a timestamp:
accesslog.format = "%{%s}t|%V|%r|%s|%b"
Recently we added a new field, but the date format is still the same:
accesslog.format = "%{%s}t|%h|%V|%r|%s|%b"
My suggestion would be to use the same date format for access log:
accesslog.format = "%{%F %X}t|%h|%V|%r|%s|%b"
2023-02-17 18:17:20|<IP_orig>|<IP_dest>|GET /admin/api_db.php?status HTTP/1.1|200|19
2 Likes
Is it possible to do something like accesslog.format += "%t|%h|%V|%r|%s|%b"
in an additional .conf
file?
I'm hesitant to change log output format since we know there are a number of users and configurations that rely on a specific log format. Changing will break all of those.
The lighttpd
daemon is new enough to know how to use the +=
notation to specify that you want to override an existing configuration statement.
2 Likes
You can add an additional config file, but the accesslog.format
option is inside a conditional statement.
This means the additional config should be using the same condition. I also think the operator needs to be :=
:
$HTTP["url"] =~ "^/admin/" {
accesslog.format := "<whatever format string you like>"
}
Also, the additional file should be loaded AFTER 15-pihole-admin.conf
. Something like 20-pihole-accesslog.conf
should be fine.
2 Likes