5

I am working with spring boot application where I am using logback for LOGGING purpose and I want to store my log on log file with unlimited size but default size of logging.file.max-size property is 10MB can anyone help me that what value I need to set on logging.file.max-size to achieve unlimited file size for log file?

Piyush Chaudhari
  • 962
  • 3
  • 19
  • 41
  • I think you should not go for unlimited size. Perhaps it is appropriate to have an unlimited amount of logfiles, but: what do you want to do with logs that are several months old ? – Marged Sep 18 '18 at 06:07

3 Answers3

7

There is no way to set an unlimited size as such, but there is a workaround
You can set a huge limit for the max size, like this:

logging.file.max-size: 100000GB

Set this in application.yml or application-test.yml
If your machine has more than 100,000 GB of disk space, you can use a higher number ;].

Background:
Spring boot loads this default config file: org/springframework/boot/logging/logback/base.xml
That file includes: org/springframework/boot/logging/logback/file-appender.xml
Which uses SizeAndTimeBasedRollingPolicy

davidfrancis
  • 3,734
  • 2
  • 24
  • 21
6

Log files rotate when they reach 10 MB and, as with console output, ERROR-level, WARN-level, and INFO-level messages are logged by default. Size limits can be changed using the logging.file.max-size property. Previously rotated files are archived indefinitely unless the logging.file.max-history property has been set.

More customization you can do for logging, please refer Spring Boot Logging

kj007
  • 6,073
  • 4
  • 29
  • 47
0

add below in your logback.xml

<timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>5MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
avinash kumar
  • 475
  • 6
  • 10