5 Replies Latest reply on Jan 24, 2015 12:15 PM by wdfink

    remove logs older than x days from /standalone/log directory

    cipri78

      Hi,

      I an new to JBoss and I need to know how to delete the old log files from /standalone/log. We are using jboss-eap 6.2.

      i tried modifying the standard.xml and standard-ha.xml with the following, but this did now work.

       

      <size-rotating-file-handler name="FILE">

                <formatter>

                     <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                </formatter>

                <file relative-to="jboss.server.log.dir" path="server.log"/>

                <max-backup-index value="30"/>

                <append value="true"/>

           </size-rotating-file-handler>

       

      This did not remove any of the older than 30 days as I would have thought it would do, and when I checked the logs, under /standalone/log I found the following error.

       

      08:04:59,502 DEBUG [org.jboss.as.config] (MSC service thread 1-7) VM Arguments: -D[Standalone] -XX:+UseCompressedOops -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.

      08:05:00,098 ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse

          at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:141) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.server.ServerService.boot(ServerService.java:324) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:253) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]

      Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[103,13]

      Message: JBAS014788: Unexpected attribute 'max-backup-index' encountered

          at org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute(ParseUtils.java:105) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.logging.LoggingSubsystemParser.parsePeriodicRotatingFileHandlerElement(LoggingSubsystemParser.java:679) [jboss-as-logging-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.logging.LoggingSubsystemParser.readElement(LoggingSubsystemParser.java:181) [jboss-as-logging-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.logging.LoggingSubsystemParser.readElement(LoggingSubsystemParser.java:115) [jboss-as-logging-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final-redhat-2.jar:1.1.0.Final-redhat-2]

          at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final-redhat-2.jar:1.1.0.Final-redhat-2]

          at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:1024) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:458) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:145) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final-redhat-2.jar:1.1.0.Final-redhat-2]

          at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final-redhat-2.jar:1.1.0.Final-redhat-2]

          at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:133) [jboss-as-controller-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          ... 3 more

        • 1. Re: remove logs older than x days from /standalone/log directory
          wdfink

          I change a log configuration (fresh installation) like this in standalone.xml:

           

          <size-rotating-file-handler name="FILE" autoflush="true">

            <formatter>

              <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

            </formatter>

            <file relative-to="jboss.server.log.dir" path="server.log"/>

            <max-backup-index value="1"/>

            <append value="false"/>

            <rotate-size value="150"/>

          </size-rotating-file-handler>

           

          And this work as expected, because of the small size it will create the backups until start.

          But you are talking about 30days, but the size rotating will keep 30 backups in your case and it depend on the log traffic and given rotate-size how much files are created.

          If you need a daily based cleanup I would use the default periodic handler and remote the files old files by a simple cron task.

          Does that makes sense?

          • 2. Re: remove logs older than x days from /standalone/log directory
            cipri78

            Hi,

            for whatever reason this does not work for me...i used your script and still no success.

            we are using jboss 1.3..

            • 3. Re: remove logs older than x days from /standalone/log directory
              wdfink

              Did you use a fresh EAP server? I've used a fresh EAP6.2 and change the periodic-rotating to size-rotating like I show.

              What version you mean 1.3 isn't a valid one did you mean EAP6.2 as you mention initially or moved to EAP6.3?

              • 4. Re: remove logs older than x days from /standalone/log directory
                cipri78

                true, we are using EAP 6.2; when i mentioned 1.3, i was referring to this: <subsystem xmlns="urn:jboss:domain:logging:1.3">

                 

                once again, i am new to this stuff and may not have a proper understanding of all the facts

                • 5. Re: remove logs older than x days from /standalone/log directory
                  wdfink

                  In this case you might wrote an invalid configuration.

                  I would start with a fresh server and change it by CLI commands which help with a tab completition feature.

                  Also you should read the documentation.