java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^

QOS.ch JIRA | Anton Wiedermann | 3 years ago
  1. 0

    In an attempt to upgrade to latest logback I hit problem with new version not being able to properly replace variable value if that variable has defualt. Version which I am upgrading from is 0.9.24 so I can not really tell when this was introduced. I searched Jira and found issues where similar functionality was not working (leaving bracket behind) but this is different problem. Simplified definition of what we have as appender {code:xml} <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> ... <file>${LOG_PATH}_trace.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern> ${ARCHIVE_PATH}_trace_${ARCHIVE_SUFFIX} </FileNamePattern> <MaxHistory>10</MaxHistory> </rollingPolicy> ... </appender> {code} and variables are defined in separate file logback.properties {code:none} LOG_HOME=${logfilepath.default:-logs} LOG_PATH=${LOG_HOME}/${APP_NAME} ARCHIVE_PATH=${LOG_HOME}/archive/${APP_NAME} {code} Above configuration fails for both RollingPolicy/FileNamePattern and appender/file with exceptions indicating that substitution for default value failed (exception below is for the RollingPolicy but same thing happens for appender/file when I correct the pattern for policy) {code:none} 13:34:55,636 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 13:34:55,652 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [TRACE_FILE] 13:34:55,744 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.boolex.JaninoEventEvaluator] for [evaluator] property 13:34:56,005 |-INFO in ch.qos.logback.classic.boolex.JaninoEventEvaluator@14bc1199 - Adding [return] prefix and a semicolon suffix. Expression becomes [return marker!=null && "audit".equals(marker.getName());] 13:34:56,005 |-INFO in ch.qos.logback.classic.boolex.JaninoEventEvaluator@14bc1199 - See also http://logback.qos.ch/codes.html#block 13:34:56,423 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use zip compression 13:34:56,429 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern ${logfilepath.default:-logs}/archive/comms_trace_%d{yyyyMMddHHmm}.log for the active file 13:34:56,439 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyyMMddHHmm' from file name pattern '${logfilepath.default:-logs}/archive/comms_trace_%d{yyyyMMddHHmm}.log.zip'. 13:34:56,439 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over every minute. 13:34:56,446 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Jan 21 13:34:56 CET 2014 13:34:56,516 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:16 - RuntimeException in Action for tag [appender] java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^ at java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^ at at java.util.regex.Pattern.error(Pattern.java:1924) at at java.util.regex.Pattern.closure(Pattern.java:3104) at at java.util.regex.Pattern.sequence(Pattern.java:2101) at at java.util.regex.Pattern.expr(Pattern.java:1964) at at java.util.regex.Pattern.compile(Pattern.java:1665) at at java.util.regex.Pattern.<init>(Pattern.java:1337) at at java.util.regex.Pattern.compile(Pattern.java:1022) at at java.util.regex.Pattern.matches(Pattern.java:1128) at at java.lang.String.matches(String.java:2063) at at ch.qos.logback.core.rolling.RollingFileAppender.fileAndPatternCollide(RollingFileAppender.java:96) at at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:67) at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96) at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) ... {code} Changing the logback.properties to following resolves the problem {code:none} LOG_PATH=${logfilepath.default:-logs}/${APP_NAME} ARCHIVE_PATH=${logfilepath.default:-logs}/archive/${APP_NAME} {code} Unfortunately we can not release that to customers for reasons which are beyond this issue. Old version of logback does not roll files which do not get written every day so we need to upgrade...

    QOS.ch JIRA | 3 years ago | Anton Wiedermann
    java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^
  2. 0

    In an attempt to upgrade to latest logback I hit problem with new version not being able to properly replace variable value if that variable has defualt. Version which I am upgrading from is 0.9.24 so I can not really tell when this was introduced. I searched Jira and found issues where similar functionality was not working (leaving bracket behind) but this is different problem. Simplified definition of what we have as appender {code:xml} <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> ... <file>${LOG_PATH}_trace.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern> ${ARCHIVE_PATH}_trace_${ARCHIVE_SUFFIX} </FileNamePattern> <MaxHistory>10</MaxHistory> </rollingPolicy> ... </appender> {code} and variables are defined in separate file logback.properties {code:none} LOG_HOME=${logfilepath.default:-logs} LOG_PATH=${LOG_HOME}/${APP_NAME} ARCHIVE_PATH=${LOG_HOME}/archive/${APP_NAME} {code} Above configuration fails for both RollingPolicy/FileNamePattern and appender/file with exceptions indicating that substitution for default value failed (exception below is for the RollingPolicy but same thing happens for appender/file when I correct the pattern for policy) {code:none} 13:34:55,636 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 13:34:55,652 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [TRACE_FILE] 13:34:55,744 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.boolex.JaninoEventEvaluator] for [evaluator] property 13:34:56,005 |-INFO in ch.qos.logback.classic.boolex.JaninoEventEvaluator@14bc1199 - Adding [return] prefix and a semicolon suffix. Expression becomes [return marker!=null && "audit".equals(marker.getName());] 13:34:56,005 |-INFO in ch.qos.logback.classic.boolex.JaninoEventEvaluator@14bc1199 - See also http://logback.qos.ch/codes.html#block 13:34:56,423 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use zip compression 13:34:56,429 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern ${logfilepath.default:-logs}/archive/comms_trace_%d{yyyyMMddHHmm}.log for the active file 13:34:56,439 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyyMMddHHmm' from file name pattern '${logfilepath.default:-logs}/archive/comms_trace_%d{yyyyMMddHHmm}.log.zip'. 13:34:56,439 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over every minute. 13:34:56,446 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Jan 21 13:34:56 CET 2014 13:34:56,516 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@28:16 - RuntimeException in Action for tag [appender] java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^ at java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^ at at java.util.regex.Pattern.error(Pattern.java:1924) at at java.util.regex.Pattern.closure(Pattern.java:3104) at at java.util.regex.Pattern.sequence(Pattern.java:2101) at at java.util.regex.Pattern.expr(Pattern.java:1964) at at java.util.regex.Pattern.compile(Pattern.java:1665) at at java.util.regex.Pattern.<init>(Pattern.java:1337) at at java.util.regex.Pattern.compile(Pattern.java:1022) at at java.util.regex.Pattern.matches(Pattern.java:1128) at at java.lang.String.matches(String.java:2063) at at ch.qos.logback.core.rolling.RollingFileAppender.fileAndPatternCollide(RollingFileAppender.java:96) at at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:67) at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96) at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196) at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) ... {code} Changing the logback.properties to following resolves the problem {code:none} LOG_PATH=${logfilepath.default:-logs}/${APP_NAME} ARCHIVE_PATH=${logfilepath.default:-logs}/archive/${APP_NAME} {code} Unfortunately we can not release that to customers for reasons which are beyond this issue. Old version of logback does not roll files which do not get written every day so we need to upgrade...

    QOS.ch JIRA | 3 years ago | Anton Wiedermann
    java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^
  3. 0

    Yaml parsing exception handling

    GitHub | 2 years ago | cebaa
    java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${profiles} ^
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Exception when I invoke increment in certain context

    GitHub | 4 years ago | ksafonov
    java.util.regex.PatternSyntaxException: Unclosed group near index 23 input(data-bind="value: ^
  6. 0

    "Dangling meta character" '+' not accepted as test description

    GitHub | 4 years ago | tim8dev
    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 36 .*percolate search over many names (+40k) in less than a few millies.* ^

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.util.regex.PatternSyntaxException

      Illegal repetition near index 0 ${logfilepath.default:-logs}/archive/comms_trace_\d{4}\d{2}\d{2}\d{2}\d{2}.log.zip ^

      at java.util.regex.Pattern.error()
    2. Java RT
      String.matches
      1. java.util.regex.Pattern.error(Pattern.java:1924)
      2. java.util.regex.Pattern.closure(Pattern.java:3104)
      3. java.util.regex.Pattern.sequence(Pattern.java:2101)
      4. java.util.regex.Pattern.expr(Pattern.java:1964)
      5. java.util.regex.Pattern.compile(Pattern.java:1665)
      6. java.util.regex.Pattern.<init>(Pattern.java:1337)
      7. java.util.regex.Pattern.compile(Pattern.java:1022)
      8. java.util.regex.Pattern.matches(Pattern.java:1128)
      9. java.lang.String.matches(String.java:2063)
      9 frames
    3. Logback Core Module
      GenericConfigurator.doConfigure
      1. ch.qos.logback.core.rolling.RollingFileAppender.fileAndPatternCollide(RollingFileAppender.java:96)
      2. ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:67)
      3. ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
      4. ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
      5. ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
      6. ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
      7. ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
      8. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
      9. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
      10. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
      11. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
      11 frames
    4. Logback Classic Module
      ContextInitializer.autoConfig
      1. ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
      2. ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
      2 frames
    5. SLF4J LOG4J-12 Binding
      StaticLoggerBinder.<clinit>
      1. org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
      2. org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
      2 frames
    6. SLF4J API Module
      LoggerFactory.getLogger
      1. org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
      2. org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
      3. org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
      4. org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
      5. org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
      5 frames