[jboss-jira] [JBoss JIRA] (LOGMGR-120) Thread local log level overriding

James Perkins (JIRA) issues at jboss.org
Fri Apr 10 11:26:19 EDT 2015


    [ https://issues.jboss.org/browse/LOGMGR-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13057913#comment-13057913 ] 

James Perkins commented on LOGMGR-120:
--------------------------------------

I've linked a PR that works based on a system property.

{code:java}
public class Main {

    static {
        System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
        System.setProperty("org.jboss.logmanager.useThreadLocalLevel", "true");
    }

    public static void main(final String[] args) throws Exception {
        Logger.getLogger("").setLevel(Level.INFO);
        final Logger logger = Logger.getLogger(Main.class.getName());
        LogManager.setThreadLocalLogLevel(Level.FINE);
        logger.fine("Test 1");
        LogManager.setThreadLocalLogLevel(null);
        logger.fine("Test 2");
        logger.info("Test 3");
        LogManager.setThreadLocalLogLevel(Level.OFF);
        logger.info("Test 4");
    }
}
{code}

This example would only print {{Test 1}} and {{Test 3}}.

> Thread local log level overriding
> ---------------------------------
>
>                 Key: LOGMGR-120
>                 URL: https://issues.jboss.org/browse/LOGMGR-120
>             Project: JBoss Log Manager
>          Issue Type: Feature Request
>          Components: core
>    Affects Versions: 1.5.2.Final
>            Reporter: Matthew Robson
>            Assignee: James Perkins
>         Attachments: force_logging.patch
>
>
> Having the ability to force logs down to a filter no matter what the log level is set to.



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the jboss-jira mailing list