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

CompositeConfiguration logs warning "Unable to determine URI for configuration." However, the reconfiguration is completed.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.1
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None

      Description

      Hello everybody,

      I found a possible bug in class CompositeConfiguration: Unable to determine URI for configuration. However, the reconfiguration is completed.

      The solution:
      In line 154, Class CompositeConfiguration [log4j-core-2.8.1.jar] change the condition:

      if (sourceURI != null)" --> "if (sourceURI == null)
      

      Original code:

      145    @Override
      146    public Configuration reconfigure() {
      147        LOGGER.debug("Reconfiguring composite configuration");
      148        final List<AbstractConfiguration> configs = new ArrayList<>();
      149        final ConfigurationFactory factory = ConfigurationFactory.getInstance();
      150        for (final AbstractConfiguration config : configurations) {
      151            final ConfigurationSource source = config.getConfigurationSource();
      152            final URI sourceURI = source.getURI();
      153            Configuration currentConfig;
      154            if (sourceURI != null) {
      155                LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored",
      156                        config.getName());
      157                currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
      158                if (currentConfig == null) {
      159                    LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
      160                    currentConfig = config;
      161                }
      162            } else {
      163                currentConfig = config;
      164            }
      165            configs.add((AbstractConfiguration) currentConfig);
      166
      167        }
      168
      169        return new CompositeConfiguration(configs);
      170    }
      

      So it makes sense, because after that it will be tried to reload the configuration again, and if it does not work, I get a warn, otherwise is ok.

      The changed code might look like this:

          @Override
          public Configuration reconfigure() {
              LOGGER.debug("Reconfiguring composite configuration");
              final List<AbstractConfiguration> configs = new ArrayList<>();
              final ConfigurationFactory factory = ConfigurationFactory.getInstance();
              for (final AbstractConfiguration config : configurations) {
                  final ConfigurationSource source = config.getConfigurationSource();
                  final URI sourceURI = source.getURI();
                  if (sourceURI == null) {
                      LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored", config.getName());
                      Configuration currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
                      if (currentConfig == null) {
                          LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
                      }
                      else {
                          LOGGER.info("Able to reload configuration {}, changes to it will be completed", config.getName());
                          configs.add((AbstractConfiguration) currentConfig);
                      }
                  } else {
                      configs.add(config);
                  }
      
              }
      
              return new CompositeConfiguration(configs);
          }
      

      Your feedback and questions are welcome. Thanks!
      Best regards,
      rri

        Activity

        Hide
        rri Ronald Rivas added a comment -

        Hello Gary

        It works. Thank you too!

        Best regards
        R Ri

        Show
        rri Ronald Rivas added a comment - Hello Gary It works. Thank you too! Best regards R Ri
        Hide
        garydgregory Gary Gregory added a comment -

        Hi Ronald Rivas,

        Thank you for your report.

        A fix is in Git master. Please verify it and close this ticket if it works for you.

        Thank you!
        Gary

        Show
        garydgregory Gary Gregory added a comment - Hi Ronald Rivas , Thank you for your report. A fix is in Git master. Please verify it and close this ticket if it works for you. Thank you! Gary
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 5b4f3db4f5e7b24862c147b790806bca0b2d1892 in logging-log4j2's branch refs/heads/master from Gary Gregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=5b4f3db ]

        LOG4J2-1912 CompositeConfiguration logs warning "Unable to determine
        URI for configuration." However, the reconfiguration is completed.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 5b4f3db4f5e7b24862c147b790806bca0b2d1892 in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=5b4f3db ] LOG4J2-1912 CompositeConfiguration logs warning "Unable to determine URI for configuration." However, the reconfiguration is completed.

          People

          • Assignee:
            Unassigned
            Reporter:
            rri Ronald Rivas
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

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

                Development