You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by vjinaz <va...@hotmail.com> on 2010/09/22 22:56:36 UTC

log4j configuration with FixedWindowRollingPolicy

Hi,

I have the following configuration in my log4j properties file:

log4j.appender.myapp=org.apache.log4j.RollingFileAppender
log4j.appender.myapp.file=/tmp/myapp/logs/myapp.log
log4j.appender.myapp.append=true
log4j.appender.myapp.layout=org.apache.log4j.PatternLayout
log4j.appender.myapp.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
log4j.appender.myapp.MaxFileSize=2MB
log4j.appender.myapp.minIndex=1
log4j.appender.myapp.maxIndex=4
log4j.appender.myapp.fileNamePattern=myapp%i.log

I want myapp.log to roll over to myapp1.log when the former reaches 2 MB. It
works fine but the rollover creates only one file myapp1.log everytime myapp
exceeds 2 MB.

For example, for the first time when myapp.log exceeds 2MB, a file
myapp1.log is created and the contents of myapp.log and written to this
file. myapp.log becomes 0 bytes again and starts processing. The next time
myapp.log exceeds 2MB, myapp1.log should get rolled over to myapp2.log and
myapp.log should get rolled over to myapp1.log. This does not happen.
myapp.log gets rolled over to myapp1.log, but myapp1.log DOES NOT get rolled
over to myapp2.log. So at any time, there are only two logs present. I
specified the maxIndex value as 4...so i was expecting to see myapp.log,
myapp1.log, myapp2.log, and myapp3.log.

Is this because I am using an old verion of log4j jar library? Please help!
-- 
View this message in context: http://old.nabble.com/log4j-configuration-with-FixedWindowRollingPolicy-tp29783917p29783917.html
Sent from the Log4j - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: log4j configuration with FixedWindowRollingPolicy

Posted by Jacob Kjome <ho...@visi.com>.
Try using "MaxBackupIndex" instead of "maxIndex".  You can also get rid of 
"minIndex" as there is no such configuration param.  I don't think 
"fileNamePattern" is applicable either.

Jake


On Wed, 22 Sep 2010 13:56:36 -0700 (PDT)
  vjinaz <va...@hotmail.com> wrote:
> 
> Hi,
> 
> I have the following configuration in my log4j properties file:
> 
> log4j.appender.myapp=org.apache.log4j.RollingFileAppender
> log4j.appender.myapp.file=/tmp/myapp/logs/myapp.log
> log4j.appender.myapp.append=true
> log4j.appender.myapp.layout=org.apache.log4j.PatternLayout
> log4j.appender.myapp.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
> log4j.appender.myapp.MaxFileSize=2MB
> log4j.appender.myapp.minIndex=1
> log4j.appender.myapp.maxIndex=4
> log4j.appender.myapp.fileNamePattern=myapp%i.log
> 
> I want myapp.log to roll over to myapp1.log when the former reaches 2 MB. It
> works fine but the rollover creates only one file myapp1.log everytime myapp
> exceeds 2 MB.
> 
>For example, for the first time when myapp.log exceeds 2MB, a file
> myapp1.log is created and the contents of myapp.log and written to this
> file. myapp.log becomes 0 bytes again and starts processing. The next time
> myapp.log exceeds 2MB, myapp1.log should get rolled over to myapp2.log and
> myapp.log should get rolled over to myapp1.log. This does not happen.
> myapp.log gets rolled over to myapp1.log, but myapp1.log DOES NOT get rolled
> over to myapp2.log. So at any time, there are only two logs present. I
> specified the maxIndex value as 4...so i was expecting to see myapp.log,
> myapp1.log, myapp2.log, and myapp3.log.
> 
> Is this because I am using an old verion of log4j jar library? Please help!
> -- 
> View this message in context: 
>http://old.nabble.com/log4j-configuration-with-FixedWindowRollingPolicy-tp29783917p29783917.html
> Sent from the Log4j - Dev mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org