4 Replies Latest reply on Nov 8, 2017 10:53 AM by Greg Jewell

    Unable to Rotate log file on Wildfly 10.1.0

    Happy Singh Newbie

      I want to rotate log file in every hour so it will create 24 files in one day and next day 24 and so on

      So i have created a custom handler as below

      <custom-handler name="filehandler" class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler" module="org.jboss.logmanager">
          <formatter>
              <named-formatter name="PATTERN"/>
          </formatter>
          <properties>
              <property name="maxBackupIndex" value="24"/>
              <property name="rotateSize" value="10000"/>
              <property name="suffix" value=".yyyy-MM-dd-HH"/>
              <property name="append" value="true"/>
              <property name="fileName" value="${jboss.server.log.dir}/server.log"/>
          </properties>
      </custom-handler>
      

      But it gives me below error. I am using windows 64 bit.

      In Wildfly 10.1.0 it had jboss-logmanager-2.0.4.Final.jar and in some forum I read to downgradee the jar to jboss-logmanager-2.0.3.Final.jar but after downgrading it keeps writing to the same log file.

      [Server:server-one] LogManager error of type OPEN_FAILURE: Unable to rotate log file

      [Server:server-one] java.nio.file.FileSystemException: D:\wildfly10_slave1\domain\servers\server-one\log\server.log -> D:\wildfly10_slave1\domain\servers\server-one\log\server.log

      The process cannot access the file because it is being used by another process.

      [Server:server-one]

      [Server:server-one]     at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)

      [Server:server-one]     at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)

      [Server:server-one]     at sun.nio.fs.WindowsFileCopy.move(Unknown Source)

      [Server:server-one]     at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)

      [Server:server-one]     at java.nio.file.Files.move(Unknown Source)

      [Server:server-one]     at org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler.rotate(PeriodicSizeRotatingFileHandler.java:251)

      [Server:server-one]     at org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler.preWrite(PeriodicSizeRotatingFileHandler.java:232)

      [Server:server-one]     at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:60)

      [Server:server-one]     at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:76)

      [Server:server-one]     at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:314)

      [Server:server-one] 16:49:57,739 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final

      [Server:server-one]     at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:322)

      [Server:server-one]     at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:322)

      [Server:server-one]     at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:322)

      [Server:server-one]     at org.jboss.logmanager.Logger.logRaw(Logger.java:850)

      [Server:server-one]     at org.jboss.logmanager.Logger.logRaw(Logger.java:860)

      [Server:server-one]     at org.jboss.logmanager.Logger.log(Logger.java:393)

      [Server:server-one]     at org.jboss.modules.log.JDKModuleLogger.doLog(JDKModuleLogger.java:105)

      [Server:server-one]     at org.jboss.modules.log.JDKModuleLogger.doLog(JDKModuleLogger.java:97)

      [Server:server-one]     at org.jboss.modules.log.JDKModuleLogger.greeting(JDKModuleLogger.java:178)

      [Server:server-one]     at org.jboss.modules.Module.setModuleLogger(Module.java:970)

      [Server:server-one]     at org.jboss.modules.Main.main(Main.java:483)

        • 1. Re: Unable to Rotate log file on Wildfly 10.1.0
          Amit Nijhawan Newbie

          Hi,

           

          There is already raised a jira for this issue and it seems to be fixed as URL below:

           

          [LOGMGR-154] Log rotations should be more resilient to failed rotations - JBoss Issue Tracker

           

          Can you please try using the latest jboss log manger from this link Maven Repository: org.jboss.logmanager » jboss-logmanager  and let us know if you still face any issue.

           

          Regards,
          Amit

           

           

          • 2. Re: Unable to Rotate log file on Wildfly 10.1.0
            Happy Singh Newbie

            I have tried that solution

            I upgraded jboss-logmanager to latest jar i.e. jboss-logmanager-2.1.0.Alpha5.jar but I got the same exception and also for this I had to upgrade org.wildfly.common module. Whe I decompiled the source code they have changed the code.

             

            Also In the JIRA site it is mentioned that It is fixed in jboss-logmanager-2.0.8-Final but this jar does not exist.

            • 3. Re: Unable to Rotate log file on Wildfly 10.1.0
              James Perkins Master

              A bit OT, but you don't have to decompile the source it's all available on GitHub .

               

              The JIRA is really more about being more resilient to stop logging from happening. The error would still print as it is a legitimate error. Something is holding a lock on the file and it's failing move a file. I've seen this issue caused by a virus scanner scanning the file while the log manager is attempting to move it. There could be other scenarios too, but that seems to be the most common.

               

              It is also correct that 2.0.8.Final has not been released. However I can do a release of this soon so you can try an upgrade.

               

              --

              James R. Perkins

              • 4. Re: Unable to Rotate log file on Wildfly 10.1.0
                Greg Jewell Novice

                This is just a guess, but could the fact that you are supplying both a time-based and size-based rotation be causing issues?  Have you tried to remove the "rotate-size" property?  The "maxBackupIndex" could be causing problems too.  For size-based rotations, the log file is appended with a number, up to the max index you specify.  I don't know whether that also handles time-based rotations, which have the suffix you specified.

                 

                Edit:  I just noticed that you are also specifying the PeriodicSizeRotatingFileHandler.  If you truly want to rotate only based on time, you should be using the PeriodicRotatingFileHandler.

                 

                Edit2:  Sorry the the couple of edits.  You may also want to consider converting your custom-handler to a "standard" handler, since you are not truly doing anything customized.  I think you'd have to explicitly put in your pattern in that case, though.  I don't know whether you can reference a pattern that is defined elsewhere.