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

How to delete rolled over folder older than six months.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Question
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0-rc1
    • None
    • Appenders
    • Java 7

    Description

      My application is using Rolling file appender. So the log files are daily rolled over to the folder having name yyyy-MM. ie 2014-03, 2014-04, 2014-05 etc. Now the requirement is to delete 6 months older folder from the path.

      Is there any configuration to achieve this?

      The current configuration is as below.
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
      <properties>
      <property name="logPattern">%c|%K

      {sessionId}

      |%t|%d

      {MM/dd/yyyy HH:mm:ss.SSS}

      |%p|%C|%M|%L|%K

      {msg}

      %n</property>
      <property name="filePattern">${sys:logfilepath}//$${date:yyyy-MM}//${sys:oft.appserver}out%d

      {yyyy-MM-dd}

      .log</property>
      <property name="fileName">${sys:logfilepath}//${sys:oft.appserver}-out.log</property>
      </properties>
      <appenders>
      <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="logPattern"/>
      </Console>
      <RollingFile name="RollingFile" fileName="${fileName}" filePattern="${filePattern}">
      <PatternLayout>
      <pattern>${logPattern}</pattern>
      </PatternLayout>
      <Policies>
      <TimeBasedTriggeringPolicy />
      </Policies>
      </RollingFile>
      </appenders>
      <loggers>
      <AsyncLogger name="logtype" level="info" includeLocation="true" additivity="false">
      <AppenderRef ref="RollingFile"/>
      </AsyncLogger>
      <root level="info">
      <AppenderRef ref="Console"/>
      </root>
      </loggers>
      </configuration>

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sivan sivan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment