1

My spring application running Log4j through common-logging and slf4j-log4j12 In the following setting

log4j.appender.ROL=org.apache.log4j.RollingFileAppender
log4j.appender.ROL.Encoding=Unicode
log4j.appender.ROL.File=E:\\I_Told_Ya.log
log4j.appender.ROL.MaxFileSize=100000
log4j.appender.ROL.MaxBackupIndex=10
log4j.appender.ROL.layout=org.apache.log4j.PatternLayout
log4j.appender.ROL.layout.ConversionPattern=%d -- %p -- %c -- %m%n

When I set

MaxFileSize=10000000

each log file grows until 19,488kb

When I set

MaxFileSize=10000000

each log file grows until 196kb

When I set

MaxFileSize=10Mb

each log file grows until 20,000kb

Log4J always double the log size from my setting

So what is going on?

these are my dependencies

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>apache-log4j-extras</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
Dreamer
  • 7,333
  • 24
  • 99
  • 179
  • 1
    By curiosity, what does setting `Encoding` to `Unicode` mean? Unicode is not an encoding to start with... – fge Feb 18 '14 at 00:06
  • @fge. You get sharp vision, that is the problem ! thanks! – Dreamer Mar 06 '14 at 20:25
  • Uh, you mean you don't have the problem anymore if you replace that with (I guess) UTF-8? – fge Mar 06 '14 at 20:56
  • @fge yes. I mean, it works fine immediately with rolling per 10 Mb, but still stop rolling sometimes after a while. Open another thread [http://stackoverflow.com/questions/22234765/does-scheduler-start-a-new-thread?noredirect=1#comment33764409_22234765](here). But think it is a thread related issue. Just want to say you definitely nail the primary cause :) – Dreamer Mar 06 '14 at 21:09

0 Answers0