Logfile timestamp format

1. My Caddy version (caddy -version):

Caddy v1.0.4

2. How I run Caddy:

sudo caddy -conf caddyfile

a. System environment:

debian 7.11 (wheezy) on R3188 device.

d. My complete Caddyfile:

http://ipv4.tld:80, http://ipv6.tld:80 {
root /home/caddy/web
gzip
log access.log
errors error.log
ipfilter / {
rule allow
blockpage def.html
database /home/caddy/geolite/GeoLite2-Country.mmdb
country TLD TLD2
}
ipfilter /myhost/myfolder {
rule allow
blockpage def.html
country TLD TLD2
}
gzip
gzip {
level 6
not /images /videos
}
}

3. The problem I’m having:

It is not a problem, but I’d be thankful if you will let me know how to change this 1.0.4 format in logfile:
2019/12/25 10:43:02 IP.IP.IP.IP - - [25/Dec/2019:10:43:02 +0300] “GET / HTTP/1.1” 200 798

to exact format I’d like to see:
2019.12.25 10:43:02 IP.IP.IP.IP “GET / HTTP/1.1” 200 798

Thanks in advance!

Hi @nmr50,

The default log format is given in the log documentation:

  • {common} (default)
{remote} - {user} [{when}] \"{method} {uri} {proto}\" {status} {size}

https://caddyserver.com/v1/docs/log#log-format

You can specify your own logging format with the syntax log path file [format].

Simply take the default format and modify it to suit your requirements, then specify it in place of [format].

Whitestrake: Hello ! Can you, please, specify how to change 2019/12/25 date format to 2019.12.25 ?

I don’t see no strftime/date format options for the logfile in docs you mentioned (and I did read earlier)…

My apologies, I didn’t note the conversion of slashes to dots.

To my knowledge, this kind of replacement is not possible when configuring the log output.

I’d advise you use modern log parsing software to make this a non-issue.

If it’s absolutely necessary to prepare logs in this manner, a simple script could be written which would be able to convert the slashes in the date to dots before viewing the logs.

1 Like

(FWIW this is totally doable and easy in Caddy 2. You can customize the time format and other things for your encoder of choice. JSON Config Structure - Caddy Documentation)

1 Like

matt: What I see threre is a total KISS principle denial for such simple option - to set desired date format according to STANDARD strftime and/or date format options…it’s not good, ppl…

Relax; believe it or not, it is more complicated than you think. There are many standard formats, and there are a lot of demands from people other than yourself who have different requirements. Please do not be upset at the developers of the free software. :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.