You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2021/12/22 23:21:00 UTC

[jira] [Comment Edited] (LOG4J2-3251) Weblookup ${web:rootDir} is not working if old loggercontext is removed and tried to initialize loggerContext using Configurator.initialize

    [ https://issues.apache.org/jira/browse/LOG4J2-3251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17464160#comment-17464160 ] 

Ralph Goers edited comment on LOG4J2-3251 at 12/22/21, 11:20 PM:
-----------------------------------------------------------------

What you are doing sounds invalid. LoggerContext's are tied to the ClassLoader. You can't just create another one. Code that simply calls LogManager.getLoggerContext() or LogManager.getLogger() (which calls getLoggerContext()) is not going to be able to find your new LoggerContext.

 

It would be helpful if you provided information on what your end goal is so perhaps we could explain how to do it. But that should happen on the dev mailing list, not in Jira.


was (Author: ralph.goers@dslextreme.com):
What you are doing sounds invalid. LoggerContext's are tied to the ClassLoader. You can't just create another one. Code that simply calls LogManager.getLoggerContext() or LogManager.getLogger() (which calls getLoggerContext()) is not going to be able to find your new LoggerContext.

> Weblookup ${web:rootDir} is not working if old loggercontext is removed and tried to initialize loggerContext using Configurator.initialize
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3251
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3251
>             Project: Log4j 2
>          Issue Type: Wish
>          Components: Configurators
>    Affects Versions: 2.15.0, 2.16.0
>            Reporter: Sankalp
>            Priority: Blocker
>              Labels: weblookup
>         Attachments: console.log
>
>
> In a web application, I am first creating a loggerContext and it log4j.xml  has ${web:rootDir} for lookup. It is resolved as expected. 
> I am removing the older loggerContext and using Configurator.initialize(contextName, classlodaer, filePaths, context). This API fails and I can observe that inside weblookup it is NOT getting servletContext. Below API returns null. 
> *ServletContext ctx = WebLoggerContextUtils.getServletContext();*



--
This message was sent by Atlassian Jira
(v8.20.1#820001)