# Terminate after warning is thrown - global setting

**URL:** <https://discourse.julialang.org/t/terminate-after-warning-is-thrown-global-setting/80368>\
**Category:** General Usage\
**Tags:** warning, control-flow\
**Created:** [May 2, 2022, 2:17pm UTC](https://discourse.julialang.org/t/terminate-after-warning-is-thrown-global-setting/80368 "2022-05-02T14:17:06Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [May 2, 2022, 2:45pm UTC](https://discourse.julialang.org/t/terminate-after-warning-is-thrown-global-setting/80368/3 "2022-05-02T14:45:15Z")

</div>

You can install a custom logger that eg. terminates the process for messages with level higher than warnings:

```julia
julia> using Logging, LoggingExtras

julia> terminator = EarlyFilteredLogger(global_logger()) do log_args
           if log_args.level >= Logging.Warn
               println(stderr, "ERROR: Log message with higher level than Logging.Warn, terminating process.")
               exit(-1)
           end
           return true
       end;

julia> global_logger(terminator);

julia> @info "hello"
[ Info: hello

julia> @warn "world"
ERROR: Log message with higher level than Logging.Warn, terminating process.

$ # back to shell prompt

```

---

_[View the full topic](https://discourse.julialang.org/t/terminate-after-warning-is-thrown-global-setting/80368)._
