6 Replies Latest reply on Jul 25, 2012 2:44 PM by mike just

    .yyyyMMdd.log logging format

    mike just Master

      Can JBoss 7.1 logging format be configured as filename.yyyyMMdd.log for the file handler? Why I am trying to do is because I want to search .log files based on the .log extension instead of .yyyyMMdd extension.


      I tried following settings but for the log file in current day, it is named demo with no extension .log which is not what I want. Is there a better way to do this?


      <periodic-rotating-file-handler name="demo" autoflush="true">
                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                      <file relative-to="jboss.server.log.dir" path="../../../../logs/demo"/>
                      <suffix value=".yyyyMMdd.log"/>
                      <append value="true"/>
        • 1. Re: .yyyyMMdd.log logging format
          James Perkins Master

          It will only append the date when the file is set to rotate. In the version of JBoss Log Manager that is shipped with 7.1.x it didn't look at the file date on startup to determine when to rotate the file. You should be able to replace the library with no adverse effects.



          James R. Perkins

          • 2. Re: .yyyyMMdd.log logging format
            mike just Master

            Hi James,


            What library do you mean can do what I required?

            1. configured as filename.yyyyMMdd.log

            2. for the log file in current day, it is not named without extension .log

            • 3. Re: .yyyyMMdd.log logging format
              James Perkins Master


              There is no way, at least that I can think of, to append the date to the file by default. You could extend the org.jboss.logmanager.handlers.PeriodicRotatingFileHandler and create your own handler that would append the date to the end of the current file. Then just set it up as a custom handler.


              You can download the latest log manager at https://repository.jboss.org/nexus/index.html#view-repositories;releases~browsestorage~/org/jboss/logmanager/jboss-logmanager/1.3.1.Final/jboss-logmanager-1.3.1.Final.jar. Put that jar in the ${JBOSS_HOME}/modules/org/jboss/logmanager/main directory. Then edit the module.xml and change the path to the new jar.



              <?xml version="1.0" encoding="UTF-8"?>
                ~ JBoss, Home of Professional Open Source.
                ~ Copyright 2010, Red Hat, Inc., and individual contributors
                ~ as indicated by the @author tags. See the copyright.txt file in the
                ~ distribution for a full listing of individual contributors.
                ~ This is free software; you can redistribute it and/or modify it
                ~ under the terms of the GNU Lesser General Public License as
                ~ published by the Free Software Foundation; either version 2.1 of
                ~ the License, or (at your option) any later version.
                ~ This software is distributed in the hope that it will be useful,
                ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
                ~ Lesser General Public License for more details.
                ~ You should have received a copy of the GNU Lesser General Public
                ~ License along with this software; if not, write to the Free
                ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
                ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
              <module xmlns="urn:jboss:module:1.1" name="org.jboss.logmanager">
                      <resource-root path="jboss-logmanager-1.3.1.Final.jar"/>
                      <!-- Insert resources here -->



              James R. Perkins

              • 4. Re: .yyyyMMdd.log logging format
                mike just Master

                Thank you James, do you mean in current JBoss (7.1.1.Final) we can not create our own custom log handler using jboss-logmanager-1.2.2.GA.jar so I need to use the latest jar jboss-logmanager-1.3.1.Final.jar?


                And where can the custom handler class be put so that the custom-handler can load with class attribute? Or besides class attribute, any other attributes (like module?) need to be used for this purpose? And if you can post a short of sample code for the custom handler class, it will be much appreciated.

                • 5. Re: .yyyyMMdd.log logging format
                  James Perkins Master


                  You can use the 1.2.2.GA version, but it will only rotate if the application server has been up for a day. Meaning if you start it today, stop it before midnight and restart tomorrow no rotating would happen. Of course you could fix that in your extended version.


                  This is a pretty good article on how to write and use a custom handler https://community.jboss.org/wiki/CreatingACustomLoggingHandlerInJBOSSAs710Final.



                  James R. Perkins

                  • 6. Re: .yyyyMMdd.log logging format
                    mike just Master

                    Thanks so much, James. I will read it carefully and have a try.