Maximum Backup Size in Log4J ERROR
I use log4j in my applications for manage the log files. Now, I want to manage the number of backups and the maximum log size. For this, I use two methods of the API of log4j:
setMaxBackupIndex(int maxBackups);
setMaximumFileSize(long maxSize);
The first works correctly, but the second not works. I configure the maximum size in 1024 bytes but the size of the files is 1066 bytes.
Anyone know how fix it?
Thanks! Regards, yebenes.
Re: Maximum Backup Size in Log4J ERROR
This happens because of the way RollingFileAdapter works (which I presume you are using because you did not include much information otherwise) - it appends, then checks maximum file size and rolls over (for the next append) if the file size is equal to or exceeds the maximum set value.
Re: Maximum Backup Size in Log4J ERROR
Exactly, I use a RollingFileAdapter. Thanks for the information :)