# Selectively enable debug level logging with a custom \`global\_logger\`

**URL:** https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286
**Category:** General Usage
**Tags:** logging
**Created:** [March 31, 2021, 11:33am UTC](https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286 "2021-03-31T11:33:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dm3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dm3/32/2755_2.png) [@dm3](https://discourse.julialang.org/u/dm3)
#### Post date: [March 31, 2021, 11:33am UTC](https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286/1 "2021-03-31T11:33:16Z")

</div>

Hello! I’m at a loss on how to selectively enable debug logging when overriding a global logger. If I override the `global_logger` like this:

ConsoleLogger(stdout, Logging.Info) |\> global\_logger

then setting `ENV["JULIA_DEBUG"]="MyModule"` doesn’t have any effect because the `min_level` is INFO. However, if I set `min_level` to DEBUG - all of the debug statements get logged. `JULIA_DEBUG` seems to have no effect…

Would be grateful for any pointers!

---

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [March 31, 2021, 12:24pm UTC](https://discourse.julialang.org/t/selectively-enable-debug-level-logging-with-a-custom-global-logger/58286/2 "2021-03-31T12:24:24Z")

</div>

the `ENV["JULIA_DEBUG"]` thing is a mess, that @c42f have been talking about replacing for years.  
See [DemuxLogger does not work with JULIA\_DEBUG? · Issue #20 · JuliaLogging/LoggingExtras.jl · GitHub](https://github.com/oxinabox/LoggingExtras.jl/issues/20)

I suggest [LoggingExtras](https://github.com/oxinabox/LoggingExtras.jl) is a much better solution.  
I would do something like (not tested).

```julia
using LoggingExtras

global_logger(EarlyFilteredLogger(ConsoleLogger(stdout, BelowMinLevel)) do log
    # Keep any messages from MyModule or of Info level or greater
    log._module == MyModule || log.level >= Info
end)

```
