Q:

logback error while server startup

The following is my logback file
<?xml version="1.0" encoding="UTF-8"?>

<!-- For assistance related to logback-translator or configuration -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
<!-- -->
<!-- For professional support please see -->
<!-- http://www.qos.ch/shop/products/professionalSupport -->
<!-- -->
<configuration>

    <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
    <!-- in the absence of the class attribute, it is assumed that the
         desired discriminator type is
         ch.qos.logback.classic.sift.MDCBasedDiscriminator -->
        <discriminator>
            <key>type</key>
            <defaultValue>normal</defaultValue>
        </discriminator>
        <sift>
            <appender name="STDOUT-${type}" class="ch.qos.logback.core.ConsoleAppender">
                <file>${catalina.base}/logs/${type}.log</file>
                <layout class="ch.qos.logback.classic.PatternLayout">
                    <Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
                    </Pattern>
                </layout>
            </appender>
            <appender name="FILE-${type}"
                class="ch.qos.logback.core.rolling.RollingFileAppender">
                <file>${catalina.base}/logs/${type}.log</file>
                <Encoding>UTF-8</Encoding>
                <!-- Current assumption: If we don't provide log file name then default will be used i.e.
                     catalina.out -->
                <!-- <file>${catalina.base}/logs/ee.log</file> -->
                <Append>true</Append>
                <layout class="ch.qos.logback.classic.PatternLayout">
                    <Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
                </layout>

                <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
                    <FileNamePattern>${catalina.base}/logs/${type}/ee.%i.log.zip
                    </FileNamePattern>
                    <MinIndex>1</MinIndex>
                    <MaxIndex>10</MaxIndex>
                </rollingPolicy>

                <triggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                    <MaxFileSize>200MB</MaxFileSize>
                </triggeringPolicy>

            </appender>
        </sift>
    </appender>

    <appender name="FILE-HIBERNATE"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${catalina.base}/logs/hibernate.log</file>
        <Encoding>UTF-8</Encoding>
        <!-- Current assumption: If we don't provide log file name then default will be used i.e.
             catalina.out -->
        <!-- <file>${catalina.base}/logs/ee.log</file> -->
        <Append>true</Append>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
        </layout>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>${catalina.base}/logs/hibernate/ee.%i.log.zip
            </FileNamePattern>
            <MinIndex>1</MinIndex>
            <MaxIndex>10</MaxIndex>
        </rollingPolicy>

        <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>200MB</MaxFileSize>
        </triggeringPolicy>

    </appender>

    <appender name="FILE-EMAIL"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${catalina.base}/logs/email.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>
                %d{yyyy-MM-dd HH:mm:ss} - %msg%n
            </Pattern>
        </encoder>
        <Append>true</Append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${catalina.base}/logs/email/email_%d{yyyy-MM-dd}.zip
            </FileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1KB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
                %msg%n</Pattern>
        </layout>
    </appender>

    <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
        <filter class="com.expertly.common.logs.filters.EmailLogFilter">
            <excludedExceptionClassName>org.springframework.security.access.AccessDeniedException</excludedExceptionClassName>
            <excludedExceptionClassName>com.expertexecution.ee.common.server.filters.RequestResponseLoggingFilter</excludedExceptionClassName>
        </filter>
        <smtpHost>localhost</smtpHost>
        <to>errors@expertly.com</to>
        <smtpPort>25</smtpPort>
        <STARTTLS>false</STARTTLS>
        <from>error-notifications@webintensive.expertexecution.com</from>
        <subject>Expertly: Error</subject>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date %-5level %logger{35} -%n %message%n</pattern>
        </layout>
    </appender>

    <root level="ERROR">
        <appender-ref ref="EMAIL" />
    </root>

    <logger name="org.hibernate.type" level="INFO" additivity="false">
        <appender-ref ref="FILE-HIBERNATE" />
    </logger>
    <logger name="org.hibernate" level="INFO" additivity="false">
        <appender-ref ref="FILE-HIBERNATE" />
    </logger>
    <!-- <logger name="com.expertexecution.ee.common.server.email" level="DEBUG" additivity="false">
        <appender-ref ref="FILE-EMAIL" />
    </logger> -->

    <root level="DEBUG">
        <appender-ref ref="SIFT" />
<!--        <appender-ref ref="FILE" /> -->
<!--        <appender-ref ref="STDOUT" /> -->
<!--        <appender-ref ref="EMAIL" /> --> 
    </root>

</configuration>

I am getting following error while I start my server. It gives array index outof bound error. Not able to understand what is the issue.
 15:36:55,735 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
    15:36:55,735 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
    15:36:55,735 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/anoop/EE%20Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/trunk/WEB-INF/classes/logback.xml]
    15:36:55,796 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
    15:36:55,797 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.sift.SiftingAppender]
    15:36:55,800 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SIFT]
    15:36:55,821 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.sift.MDCBasedDiscriminator] for [discriminator] property
    15:36:55,827 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
    15:36:55,830 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE-HIBERNATE]
    15:36:55,841 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@59:13 - no applicable action for [Encoding], current pattern is [[configuration][appender][Encoding]]
    15:36:55,876 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - This appender no longer admits a layout as a sub-component, set an encoder instead.
    15:36:55,876 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
    15:36:55,876 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
    15:36:55,885 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@74648f3f - Will use zip compression
    15:36:55,893 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - Active log file name: /home/anoop/EE Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/logs/hibernate.log
    15:36:55,893 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - File property is set to [/home/anoop/EE Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/logs/hibernate.log]
    15:36:55,894 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
    15:36:55,894 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE-EMAIL]
    15:36:55,916 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use zip compression
    15:36:55,916 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern /home/anoop/EE Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/logs/email/email_%d{yyyy-MM-dd} for the active file
    15:36:55,919 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@75f8accb - The date pattern is 'yyyy-MM-dd' from file name pattern '/home/anoop/EE Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/logs/email/email_%d{yyyy-MM-dd}.zip'.
    15:36:55,919 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@75f8accb - Roll-over at midnight.
    15:36:55,919 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@75f8accb - Setting initial period to Wed Jun 03 14:30:20 IST 2015
    15:36:55,921 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@98:19 - RuntimeException in Action for tag [rollingPolicy] java.lang.IndexOutOfBoundsException: No group 1
        at java.lang.IndexOutOfBoundsException: No group 1
        at  at java.util.regex.Matcher.group(Matcher.java:487)
        at  at ch.qos.logback.core.rolling.helper.FileFilterUtil.extractCounter(FileFilterUtil.java:109)
        at  at ch.qos.logback.core.rolling.helper.FileFilterUtil.findHighestCounter(FileFilterUtil.java:93)
        at  at ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.computeCurrentPeriodsHighestCounterValue(SizeAndTimeBasedFNATP.java:65)
        at  at ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.start(SizeAndTimeBasedFNATP.java:49)
        at  at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.start(TimeBasedRollingPolicy.java:87)
        at  at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)
        at  at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:318)
        at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:197)
        at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:183)
        at  at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
        at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:147)
        at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:133)
        at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96)
        at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:55)
        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:84)
        at  at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54)
        at  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
        at  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
        at  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
        at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
        at  at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
        at  at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
        at  at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
        at  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:282)
        at  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
        at  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
        at  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
        at  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at  at java.lang.Thread.run(Thread.java:745)
    15:36:55,921 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@99:56 - no applicable action for [layout], current pattern is [[configuration][appender][layout]]
    15:36:55,921 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@100:13 - no applicable action for [Pattern], current pattern is [[configuration][appender][layout][Pattern]]
    15:36:55,921 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-EMAIL] - No TriggeringPolicy was set for the RollingFileAppender named FILE-EMAIL
    15:36:55,921 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-EMAIL] - For more information, please visit http://logback.qos.ch/codes.html#rfa_no_tp
    15:36:55,921 |-WARN in ch.qos.logback.core.joran.action.AppenderAction - The object at the of the stack is not the appender named [FILE-EMAIL] pushed earlier.
    15:36:55,921 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
    15:36:55,934 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [EMAIL]
    15:36:55,962 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
    15:36:55,962 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [EMAIL] to Logger[ROOT]
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.type] to INFO
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.type] to false
    15:36:55,963 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE-HIBERNATE] to Logger[org.hibernate.type]
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to INFO
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate] to false
    15:36:55,963 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE-HIBERNATE] to Logger[org.hibernate]
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
    15:36:55,963 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [SIFT] to Logger[ROOT]
    15:36:55,963 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
    15:36:55,964 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@52c481c5 - Registering current configuration as safe fallback point

can anyone please help me fixing it?

A:

Just add a counter %i to the FileNamePattern whenever you use a MaxFileSize.
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <FileNamePattern>${catalina.base}/logs/email/email_%d{yyyy-MM-dd}_%i.zip</FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
         <maxFileSize>1KB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>

Checkout this post.

