[ https://issues.apache.org/jira/browse/LOG4J2-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Günter Albrecht updated LOG4J2-1045: ------------------------------------ Description: We're working with WebSphere 8.0 and our operations team has demanded to externalize the log4j2.xml file per application. So I defined a URL resource on WAS8 containing the path to the log4j2.xml somewhere on the filesystem. At first glance the solution seems very simple: I defined the property {{log4j.configurationFactory}} in the {{log4j2.component.properties}} file {{log4j.configurationFactory=de.company.MyConfigurationFactory}} available via classpath of the application. In this class I specialized the method '{{public Configuration getConfiguration(String name, URI configLocation, ClassLoader loader)}}'. There I make a lookup to the URL resource. But it does'nt function as of a missing implementation in the class {{ConfigurationFactory$Factory}} and the method {{public Configuration getConfiguration(final String name, final URI configLocation)}}. When one enters the method the variable {{configLocation}} is null. Then the property {{log4j.configurationFile}} is checked which is intentionally not set in the {{log4j2.component.properties}} file as it must be dynamical - via a URL resource. Hence also the variable config is null. Unfortunately merely {{config != null}} is handled and no else case is implemented. So my improvement is to implement an else case which is identical to the else case of {{if (configLocation == null)}}. With this solution I do not have to implement cumbersome versions for Web- and EJB-applications. was: We're working with WebSphere 8.0 and our operations team has demanded to externalize the log4j2.xml file per application. So I defined a URL resource on WAS8 containing the path to the log4j2.xml somewhere on the filesystem. At first glance the solution seems very simple: I defined the property {{log4j.configurationFactory}} in the {{log4j2.component.properties}} file {{log4j.configurationFactory=de.company.MyConfigurationFactory}} available via classpath of the application. In this class I specialized the method '{{public Configuration getConfiguration(String name, URI configLocation, ClassLoader loader)}}'. There I make a lookup to the URL resource. But it does'nt function as of a missing implementation in the class {{ConfigurationFactory$Factory}} and the method {{public Configuration getConfiguration(final String name, final URI configLocation)}}. When one enters the method the variable {{configLocation}} is null. Then the property '{{log4j.configurationFile}}' is checked which is intentionally not set in the {{log4j2.component.properties}} file as it must be dynamical - via a URL resource. Hence also the variable config is null. Unfortunately merely {{config != null}} is handled and no else case is implemented. So my improvement is to implement an else case which is identical to the else case of '{{if (configLocation == null)}}'. With this solution I do not have to implement cumbersome versions for Web- and EJB-applications. > WAS8: externalize log4j2.xml via URL resource > --------------------------------------------- > > Key: LOG4J2-1045 > URL: https://issues.apache.org/jira/browse/LOG4J2-1045 > Project: Log4j 2 > Issue Type: Bug > Components: Configurators > Affects Versions: 2.3 > Environment: WebSphere 8.0; Win7 x64 > Reporter: Günter Albrecht > Labels: patch > > We're working with WebSphere 8.0 and our operations team has demanded to > externalize the log4j2.xml file per application. > So I defined a URL resource on WAS8 containing the path to the log4j2.xml > somewhere on the filesystem. > At first glance the solution seems very simple: > I defined the property {{log4j.configurationFactory}} in the > {{log4j2.component.properties}} file > {{log4j.configurationFactory=de.company.MyConfigurationFactory}} available > via classpath of the application. > In this class I specialized the method '{{public Configuration > getConfiguration(String name, URI configLocation, ClassLoader loader)}}'. > There I make a lookup to the URL resource. > But it does'nt function as of a missing implementation in the class > {{ConfigurationFactory$Factory}} and the method {{public Configuration > getConfiguration(final String name, final URI configLocation)}}. When one > enters the method the variable {{configLocation}} is null. Then the property > {{log4j.configurationFile}} is checked which is intentionally not set in the > {{log4j2.component.properties}} file as it must be dynamical - via a URL > resource. > Hence also the variable config is null. Unfortunately merely {{config != > null}} is handled and no else case is implemented. > So my improvement is to implement an else case which is identical to the else > case of {{if (configLocation == null)}}. > With this solution I do not have to implement cumbersome versions for Web- > and EJB-applications. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org