-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Multiple appenders with different namespace filters #183
Comments
Hi Wei, hope you're well!
That's correct, these are general-purpose high-level filters to include/exclude log output entirely for matching namespaces. If you need something more sophisticated, you can just ignore those and implement your own filtering however you'd like. Timbre's inherently a very simple design, no magic:
The built-in So if you want some kind of custom conditional logic, you can either add it within your appender fn/s, or you can add some middleware. How you choose to do this is entirely up to you, it's all just fns.
Two obvious options come to mind:
In both cases you'll need to actually mod the appender fn though which might be inconvenient if you're using a built-in appender? Give me 10mins, have an idea. |
Motivating use case: let users apply custom ns-filtering or other conditional logic at an appender level *without* needing to actually modify the appender fn. This is just a natural generalization of the recently added support for appender-level ns filters, etc.
Okay have just cut Add two appenders, one that outputs to "catchall.txt" and one that outputs to "noisy.txt". Then:
So there's namespace filters at the global level, and per-appender, Does that help / make sense? |
Thanks Peter, you as well! Just tried 4.7.0 and it works great. For future reference, here's my working config: (defn timbre-config! []
(log/merge-config!
{:level :debug
:appenders {:app (assoc (appenders/spit-appender {:fname "app.log"})
:ns-blacklist ["com.noisy.*"])
:noisy (assoc (appenders/spit-appender {:fname "noisy.log"})
:ns-whitelist ["com.noisy.*"]
:min-level :info)}})) Thanks for going out of your way to cut a new release! |
👍 |
I'd like to separate my logs into different files based on namespaces. Specifically, there's one noisy namespace I'd like to route to its own file, and have a catchall file for everything else. It's not clear from the docs how to do this (
ns-blacklist
andns-whitelist
seem to be for the global level rather than appender-level), is it possible in Timbre?Thanks for making this useful library btw!
The text was updated successfully, but these errors were encountered: