Time_format examples please

Half an hour later filling it in perfectly and this submission template is giving me the hump…

“Sorry, new users can only put 4 links in a post. Remember to enclose Caddyfiles and logs with backticks (```) on empty lines immediately before and after the text - domains posted this way do not count as links.”

I’ve only pasted the link to the Caddy docs.


I’m trying to change the format of the time and date in my logs to ISO 8601 but cannot for the life of me a) figure out the documentation or b) find any working examples online.
I can see that I need to enter the below in my Caddyfile, but where in the site blocks does it go and what is the “encoder_module”?
Also, would I place “ISO8601” in the place of ?

format <encoder_module> {
	time_format  <format>

All my attempts to guess it return;

reload: adapting config using caddyfile: parsing caddyfile tokens for 'log': Caddyfile:21 - Error during parsing: getting log encoder module named 'time_format': module not registered: caddy.logging.encoders.time_format

Please help. I’ve just switched from NGINX to Caddy and desperately trying to make it fit.

If you need my Caddyfile or any further info I can try and paste in my original submission here again.

Sigh. Looks like a Discourse bug. I’m annoyed. Sorry about that.

I think you can do this:

log {
	output file /path/to/caddy.log
	format console {
		time_format iso8601

Unfortunately the time formats seem undocumented, but they’re here in the code:



Thanks, Francis. That worked a treat. I even decided to try “wall” as that looked better for readability, and it is. Although I can’t see how it works from the above snippet. Never mind, the data and time looks great now.

log {
        output file /var/lib/caddy/cloud.access.log {
                roll_size     5mib
                roll_keep     10
                roll_keep_for 168h
        format single_field common_log
        format console {
                time_format wall

But I have also noticed that this seems to have cancelled out the format single_field common_log which works without the time_format block, so I now have the wall-of-text default logging.

Can they not be used together?

You can only have one format at a time.

I don’t think you can customize common_log.

OK, fair enough. I’ll continue to have a play with the logs then. Thanks again for your help.

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