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

ASF GitHub Bot commented on LOG4J2-1721:
----------------------------------------

Github user fluxroot commented on the issue:

    https://github.com/apache/logging-log4j2/pull/176
  
    That was my initial thought as well. However, there have been a couple of 
issues which made me copy the functionality from Configurator.initialize() over 
to Log4jWebInitializerImpl.getConfigURIs():
    
    1. log4j-web is an optional dependency and only useful in a servlet 
container environment. Common code would have to go into log4j-core.
    2. Parsing config location in Log4jWebInitializerImpl.getConfigURI() is 
more complicated. In addition to resolving file URIs, we have to search WEB-INF 
and also consider servlet context name to find the matching config.
    
    The solution in Java 8 would be to pass a closure to resolve the config 
location. For Java 7 I guess there's no elegant solution for this problem (or 
maybe I'm missing something :)). So for now I would leave this fix as is.


> Composite configuration using log4jConfiguration context parameter
> ------------------------------------------------------------------
>
>                 Key: LOG4J2-1721
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1721
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Configurators, Web/Servlet
>    Affects Versions: 2.7
>            Reporter: Pastrie
>            Priority: Major
>              Labels: features
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> Log4j allows multiple configuration files to be used by specifying them as a 
> list of comma separated file paths on log4j.configurationFile property. This 
> feature is not available in web environment since the  log4jConfiguration 
> context parameter accepts a single Path/File/URI.
> My proposal is to apply some small changes in the Log4jWebInitializerImpl 
> class
> - change method getConfigURI to return List<URI> instead of URI.
> {code:title=Log4jWebInitializerImpl.java|borderStyle=solid}
> if (configLocation != null) {
>       if (configLocation.contains(",")) {
>               final String[] parts = configLocation.split(",");
>               final List<URI> uris = new ArrayList<>(parts.length);
>               for (final String part : parts) {
>                       final URL url = servletContext.getResource(part);
>                       if (url != null) {
>                               final URI uri = url.toURI();
>                               LOGGER.debug("getConfigURI found resource [{}] 
> in servletContext at [{}]", uri, configLocation);
>                               uris.add(url);
>                       }
>               }
>       }
> {code}
> - change method initializeNonJndi 
> {code:title=Log4jWebInitializerImpl.java|borderStyle=solid}
> [...]
> final List<URI> listUri = getConfigURI(location);
> this.loggerContext = Configurator.initialize(this.name, 
> this.getClassLoader(), listUri, this.servletContext);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to