Adjust log level based on http request parameter #3005
-
In a rest service I would like to enable debug/trace log output for some certain modules based on the http query. I have tried to
and then configure the EnvFilter with
This basically works, but it now also enables trace events from other crates while the span is entered (notably tokio runtime). How can I achieve this to see only the trace events from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I don't think you can do this with a single This should make it so both filters are queried and if both enable the the event, only then is it emitted. The main problem here is that you cannot set both the filters with a single env variable (or you have to parse it yourself). I am not entirely sure though because the dynamic span filters are a bit magic so please do challenge this if it doesn't work for you. Ideally, we would probably want to support this in a single filter, but there is no syntax for this right as far as I know. |
Beta Was this translation helpful? Give feedback.
I don't think you can do this with a single
EnvFilter
. What I think should work though is using two filters, the first one the same as you're currently using and another one withinfo,my_crate=trace
.This should make it so both filters are queried and if both enable the the event, only then is it emitted.
The main problem here is that you cannot set both the filters with a single env variable (or you have to parse it yourself).
I am not entirely sure though because the dynamic span filters are a bit magic so please do challenge this if it doesn't work for you.
Ideally, we would probably want to support this in a single filter, but there is no syntax for this right as far as I know.