Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1721

Composite configuration using log4jConfiguration context parameter

    Details

      Description

      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.
      Log4jWebInitializerImpl.java
      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);
      			}
      		}
      	}
      
      • change method initializeNonJndi
      Log4jWebInitializerImpl.java
      [...]
      final List<URI> listUri = getConfigURI(location);
      this.loggerContext = Configurator.initialize(this.name, this.getClassLoader(), listUri, this.servletContext);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rpastrie Pastrie
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 3h
                  3h
                  Remaining:
                  Remaining Estimate - 3h
                  3h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified