CLI tool to filter JSON access logs

Hello Caddy community.

This is a fun project I created to make monitoring my logs easier (because I love to see how popular my posts are :joy:)

It’s a command-line tool that reads the JSON access logs of Caddy and filters them based on user-specified options.

My initial intention was to build a Telegram bot that filters the logs and send them to me when I need them without having to log into the server. But then I thought I should separate the filtering logic into its own Go module, this way it can be used by other people in other ideas.

The CLI is built on that module.

It’s a pretty simple one (a typical made-for-fun project). But I can see that I will be using it a lot.

You can check out the tool here:

And the library here:

As far as I know, the common logs will no longer be available in newer versions of Caddy. I will consider that in future enhancements.


Neat! Thanks for sharing!

1 Like

That’s right, it’s removed in v2.5.0, releasing soon. You can use v2.5.0-beta.1 now to test your setup with those changes.

1 Like

Thanks Francis. The log is unmarshalled into a struct, and common log is only a field in it. I can use the other fields to create my own output format. The only challenge will be if the log json keys changed, in which case I would need to either update the code or find a way to adapt the json input to my struct.

1 Like

As noted in the release notes, remote_addr is now remote_ip and remote_port (split in two). See the rest of the logging changes:


HI @francislavoie
Are you also removing the common_log key within the file?
my little script would need some re-writing if it is the case!
Thanks in advance

What do you mean “within the file”?

common_log is completely removed from Caddy; the data in it was entirely redundant, the same data was already in other JSON fields; we were basically logging the same information twice. It was wasteful.

Fair point - i was using it as a lazy way to parse the JSON file. I will have to change and parse it properly now.

This topic was automatically closed after 14 days. New replies are no longer allowed.