Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-1153

Cannot start the application if we have custom logging configuration

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 2017.3.2
    • 2017.3.3
    • None

    Description

      Error occurs during startup if I provide custom logging configuration

      Caused by: java.lang.IllegalArgumentException: No enum constant org.wildfly.swarm.config.logging.Level.%K{LEVEL}%D{YYYY-MM-DD HH:MM:SS,SSS} %-5P (%T) [%C.%M()] %S%E%N
      	at java.lang.Enum.valueOf(Enum.java:238)
      	at org.wildfly.swarm.config.logging.Level.valueOf(Level.java:2)
      	at org.wildfly.swarm.logging.LoggingFraction.applyDefaults(LoggingFraction.java:80)
      	at org.wildfly.swarm.logging.LoggingFraction.applyDefaults(LoggingFraction.java:68)
      	at org.wildfly.swarm.logging.LoggingFraction.applyDefaults(LoggingFraction.java:43)
      	at org.wildfly.swarm.container.runtime.cdi.configurable.ConfigurableFractionBean.<init>(ConfigurableFractionBean.java:33)
      	at org.wildfly.swarm.container.runtime.cdi.FractionProducingExtension.lambda$afterBeanDiscovery$1(FractionProducingExtension.java:99)
      	... 36 more
      

      This issue should be introduced by SWARM-1135 where the following logic are added

      public LoggingFraction applyDefaults(Level level) {
              defaultColorFormatter()
                      .consoleHandler(Level.ALL, COLOR_PATTERN)
                      .rootLogger(level, CONSOLE);
      
              Properties allProps = System.getProperties();
              for (String name : allProps.stringPropertyNames()) {
                  if (isSimpleLoggerName(name)) {
                      String logger = name.substring((LoggingProperties.LOGGING + ".").length());
                      Level loggerLevel = Level.valueOf(allProps.getProperty(name).trim().toUpperCase());
                      logger(logger, (l) -> {
                          l.level(loggerLevel);
                          l.category(logger);
                          l.handler(CONSOLE);
                      });
                  }
              }
      
      
              return this;
          }
      
          protected boolean isSimpleLoggerName(String name) {
              if (!name.startsWith(LoggingProperties.LOGGING)) {
                  return false;
              }
      
              if (name.endsWith("level")) {
                  return false;
              }
      
              if (name.matches("^.*\\.handlers.[0-9]+$")) {
                  return false;
              }
      
              return true;
          }
      

      The bug is located in the isSimpleLoggerName() where it falsely treat the "swarm.logging.pattern-formatters.MY_COLOR_PATTERN.pattern" as a logger

      Attachments

        Activity

          People

            bmcwhirt@redhat.com Bob McWhirter (Inactive)
            hei1233212000_jira Harry Chan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: