Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best size for a log file in LOG4J?

I have an application that runs slow. This is because of a huge amount of loggings at DEBUG and INFO levels inside the code. I have made some modifications in the code and changed the log level to WARN and it works well now.

But there is only one log file (currently at 1.6GB). I want to use a RollingFileAppender to have more, smaller, files. What is the best (maximum) size that I should use for the appender’s MaxFileSize property so that performance won’t degrade?


1 Answers

That really depends on many factors so to answer the question, you'd have to run a profiler with various file sizes. But since log4j only writes to the log file, you can simply create files of various sizes on your system and time how long it takes.

To be able to find errors in the file, I suggest to use a DailyRollingFileAppender, though. This will make it much more simple to look for something "yesterday" or "two weeks ago".

like image 114
Aaron Digulla Avatar answered Nov 02 '25 13:11

Aaron Digulla