# How to enable debug level loging in code via Logging Package

**URL:** https://discourse.julialang.org/t/how-to-enable-debug-level-loging-in-code-via-logging-package/70777
**Category:** New to Julia
**Created:** [November 2, 2021, 2:14am UTC](https://discourse.julialang.org/t/how-to-enable-debug-level-loging-in-code-via-logging-package/70777 "2021-11-02T02:14:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![benibilme](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@benibilme](https://discourse.julialang.org/u/benibilme)
#### Post date: [November 2, 2021, 2:14am UTC](https://discourse.julialang.org/t/how-to-enable-debug-level-loging-in-code-via-logging-package/70777/1 "2021-11-02T02:14:45Z")

</div>

Hello,

Is there a way of enable debug level logging in code via Logging api. Log level seems start from Info and other than environment variable there seems to be no way of enabling debug level in code if I am not mistaken. I am newbie in julia.

I would like to state that this logging library is far more mess or weaker than any comparable library in python or ruby. I am suprised about this.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [November 2, 2021, 8:23am UTC](https://discourse.julialang.org/t/how-to-enable-debug-level-loging-in-code-via-logging-package/70777/2 "2021-11-02T08:23:34Z")

</div>

For completeness’ sake, I’ll copy my response to your github issue here as well, so that other people may find it:

You can do `ENV["JULIA_DEBUG"] = MyModule` to set it to log for calls under `MyModule`, or to `all` to log for every module. Likewise, if you set it to `nothing`, logging will stop. This is also mentioned [in the manual](https://docs.julialang.org/en/v1/stdlib/Logging/#Environment-variables), though that text should be expanded a little to document how this actually works. Seems like it just didn’t get documented in [https://github.com/JuliaLang/julia/pull/32432](https://github.com/JuliaLang/julia/pull/32432)…

In case someone wants to pick this up, [here](https://github.com/JuliaLang/julia/blob/master/stdlib/Logging/docs/src/index.md) is the doc file in question and [here](https://github.com/JuliaLang/julia/blob/8544c5a2dd6888e124006989dcc894c13b1a7892/base/logging.jl#L536-L583) is how that environment variable special cases certain values and extracts the modules to log. The linked function returns `true` or `false` depending on whether or not the environment variable contains a module or not (or is filtered out).

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [November 2, 2021, 8:49am UTC](https://discourse.julialang.org/t/how-to-enable-debug-level-loging-in-code-via-logging-package/70777/3 "2021-11-02T08:49:01Z")

</div>

```julia
julia> using Logging

# Create a logger with Debug level
julia> debug_logger = ConsoleLogger(stderr, Logging.Debug);

# Set the global logger to our debug logger
julia> global_logger(debug_logger);

julia> @debug "hello, world"
┌ Debug: hello, world
└ @ Main REPL[4]:1

```
