GitHub user little-hue edited a discussion: How to change log level dynamically 
per request level?

I want to change log level per request dynamically? If the root level is set to 
INFO, how do I change the log level to DEBUG dynamically while the application 
is running. 

I tried ThreadContext log level filter, the logger won't change to DEBUG if my 
root level is set to be INFO in the log4j2.xml. 


For example, below is the log4j2.xml in my helidon application.
```

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30" shutdownHook="disable">
    <Appenders>
        <Console name="JSONLogConsoleAppender" target="SYSTEM_OUT">
            <SpectraJsonLayout compact="false" eventEol="true"/>
        </Console>
        <Async name="AsyncCAppender" bufferSize="256">
            <AppenderRef ref="JSONLogConsoleAppender"/>
        </Async>
    </Appenders>
    <Loggers>
        <Root level="${sys:spectra-log-level:-INFO}">
            <AppenderRef ref="AsyncCAppender"/>
        </Root>
    </Loggers>
</Configuration>

```

Any suggestion on how to achieve log level change per request only? I am using 
helidon framework 

GitHub link: https://github.com/apache/logging-log4j2/discussions/3917

----
This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@logging.apache.org

Reply via email to