2 Replies Latest reply on Sep 27, 2010 8:50 AM by lukaswu

    log4j.xml and logfile name pattern

    lukaswu

      Hi all,

       

      I tweaked a bit log4j.xml in JBoss 4.0.5 to rotate log on date base not size and so far reconfiguration went fine.

       

      The only thing that bothers me is logfile name pattern after log rotation: now is servicename.log.DATE which is ok though I would prefer to have it DATE.servicename.log.

       

      So far I was not able to reconfigure it- the service name goes always first. Is there any way to append it to the end of rotated file name?

       

      Thank you for any hints.

       

      --

      luk

        • 1. Re: log4j.xml and logfile name pattern
          j-n00b

          Hi Luk!

           

          Unfortunately, there is no such option in the original log4j class. But you can have a look at the class "org.apache.log4j.DailyRollingfileAppender". Method "activateOptions()"  contains the following code:

           

          {code}

          scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));

          {code}

           

          What you can do is extend the log4j class and change the behaviour of the method. Then you add your jar to JBoss and use your class in the log4j config.

           

           

          cheers,

          Andre

          • 2. Re: log4j.xml and logfile name pattern
            lukaswu

            Well... That's what I expected... Since it is HA production for time being I wil give it up.

             

            Thank you anyway.

             

            --

            luk