Changing the time format for access_log

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing the time format for access_log

James Moe
squid 4.8

I changed the default squid log format

logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt

to present a more readable fime:
logformat sma1 %Y-%m-%dT%H:%M:%S %z.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un
%Sh/%<a %mt

This did not sit well with squid:
$ squid -k parse
...[ bunch o' stuff ]...
2019/11/19 11:32:51| Processing: logformat sma1  %Y-%m-%dT%H:%M:%S %z.%03tu %6tr
%>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
2019/11/19 11:32:51| storeDirWriteCleanLogs: Operation aborted.
2019/11/19 11:32:51| FATAL: Can't parse configuration token: '%Y-%m-%dT%H:%M:%S
%z.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt'

What is the format error?

--
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
Think.


_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Changing the time format for access_log

Alex Rousskov
On 11/19/19 2:08 PM, James Moe wrote:
> FATAL: Can't parse configuration token: '%Y-%m-%dT%H:%M:%S
> %z.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt'
>
> What is the format error?

You are using logformat %codes unsupported by Squid, such as %Y, %m, and
%d. Please search the logformat documentation for "Time related format
codes": http://www.squid-cache.org/Doc/config/logformat/

Please note that %tl and %tg codes support a parameter. That parameter
is a strftime(3) format. strftime(3) does support %Y, %m, and %d
conversion specifications.

To specify a Squid %code parameter, use {curly braces}. IIRC, modern
Squids support a natural position for such parameters -- after the
%code. Here is an untested example:

 %tl{%Y-%m-%dT%H:%M:%S}


HTH,

Alex.
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: Changing the time format for access_log

Amos Jeffries
Administrator
On 20/11/19 9:48 am, Alex Rousskov wrote:
> IIRC, modern
> Squids support a natural position for such parameters -- after the
> %code. Here is an untested example:
>
>  %tl{%Y-%m-%dT%H:%M:%S}
>

Yes, all current Squid support parameters ({arg}) being either before OR
after the code letters. That is OR, not both.

As per the docs:
"
 % [encoding] [-] [[0]width] [{arg}] formatcode [{arg}]
"

Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: Changing the time format for access_log

James Moe
On 2019-11-19 10:12 PM, Amos Jeffries wrote:

> IIRC, modern
> Squids support a natural position for such parameters -- after the
> %code. Here is an untested example:
>
>  %tl{%Y-%m-%dT%H:%M:%S}
>
  Thank you. That works quite nicely.

--
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
Think.


_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users

signature.asc (201 bytes) Download Attachment