Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to filter #18

Closed
ghost opened this issue Jul 20, 2022 · 10 comments
Closed

Is there a way to filter #18

ghost opened this issue Jul 20, 2022 · 10 comments

Comments

@ghost
Copy link

ghost commented Jul 20, 2022

Hi,
I am setting the Apache common log format as suggested and it works great ! thank you very much.

Now I think of limiting logs to only those with status 404 (or another approach to not log those with 200 or 304) if feasible.
Do you offer filtering by inclusion or exclusion ? the second option would be great (all except 200 or 304)

Thanks a lot !

@francislavoie
Copy link
Member

See caddyserver/caddy#4690

@ghost
Copy link
Author

ghost commented Jul 20, 2022

Ok thanks @francislavoie , I guess this is work in progress or being discussed. so I'm going to wait

@francislavoie
Copy link
Member

There's also this plugin which might do what you need https://github.com/leodido/caddy-conditional-logging for the time being

@ghost
Copy link
Author

ghost commented Jul 20, 2022

Unfortunately it looks outdated, checking here the link is dead
https://github.com/leodido/caddy-conditional-logging/blob/8534d30877aa34bdc083ef3cf466821fa3ade019/caddyfile.go#L18

@francislavoie
Copy link
Member

No, that's correct. Go module paths do not match github URLs.

@ghost
Copy link
Author

ghost commented Jul 20, 2022

Ok thanks a lot I'll give it a try

@ghost ghost closed this as completed Jul 20, 2022
@ghost
Copy link
Author

ghost commented Jul 20, 2022

I think of keeping transform-encoder as it looks more stable for me and the Apache common log format is working perfect.
Less retention time and more compression rotations would be fine

@francislavoie
Copy link
Member

francislavoie commented Jul 20, 2022

You can chain them together. It's not either-or.

@djt
Copy link

djt commented Sep 25, 2022

@francislavoie are you able to give an example of chaining in this context? As much as I have tried, I cannot see how it works. I am fairly new to caddy though so I blame it on that.

@francislavoie
Copy link
Member

Like this:

log {
	output stdout
	format if "status ~~ `^4`" transform {common_log}
}

if is the https://github.com/leodido/caddy-conditional-logging part followed by a condition string (as per its README), then you pass it an encoder to chain into, i.e. transform with the option {common_log}.

That said, since Caddy v2.6.0 released last week, we have a skip_log directive caddyserver/caddy#4691 which you can use to match requests you don't want to have access logged.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants