In v1, the log directive could receive a format string, and print that exact thing to syslog or stdout.
Can this be re-introduced in v2? I appreciate the move to JSON-first but my environment is one of journald-based logging, with minimal use and pressure to go to any sort of centralised logging system, so formatting an entry to something that's comfortable at first glance is very helpful.
Here's an example of one of my journald-based formats;
"{remote} - {user} [{when}] \"{method} {host}{uri} {proto}\" {status} {size} \"Referer: {>Referer}\" \"{>User-Agent}\""
It would require a non-trivial amount of allocations, is that OK?
For me personally it'll be used in a low-speed environment, but I see what you mean, maybe a small warning note would need to be added to the documentation.
Or maybe this feature can be packaged in a module, to make sure administrators explicitly want to use the feature.
This would be useful for me as I am trying to setup Goaccess and common/combined logs won't include virtual hosts or hosts header information.
An alternative would be to configure Goaccess to read Caddy's JSON I guess.
@chipironcin GoAccess should support structured logs: https://github.com/allinurl/goaccess/issues/1768
I wonder if we could do something clever with https://github.com/buger/jsonparser by first encoding as JSON using the underlying JSON encoder (because writing actual encoders is hard/tedious), and then use buger's library to peer inside the JSON according to a user's custom format string.
@ShadowJonathan, this is now available in https://github.com/caddyserver/format-encoder. Is this closable now?
Heck yes it is, thank you so much!
@Mohammed90, why did you use > instead of a dot to access the properties?
@Mohammed90, why did you use > instead of a dot to access the properties?
To be consistent with other existing logging encoders. We have another logging encoder that traverses the JSON, which is the filter encoder, and it uses > as notation for it.
Most helpful comment
@chipironcin GoAccess should support structured logs: https://github.com/allinurl/goaccess/issues/1768