Maximum File Size - supported in log4j FileAppender
Asked Answered
B

1

14

I have a requirement that I need to store audit information in a TEXT file. I planned to write the audit information using Apache Log4j.

Seems to be reliable option. But, I should be able to write the Audit information even the fileSize reaches 3GB.

Does the log4j supports the fileSize even at GigaBytes?.

Or with a Quick Question, What is the MaximumFileSize can be supported in Log4j.

NOTE : I could not go for RollingFileAppender or DailyFileAppender, I need to log the information Only in One text file, where some other components are reading this file content and doing some process.

Butterball answered 6/8, 2013 at 14:48 Comment(1)
I have a long running job writing a 7gb log file that is snappy compressed. Uncompressed it is a 63gb log file. Opening it is a little tricky. The filesystem limit on file sizes should be your only actual hurdle in a FileAppender log. So it depends. 256 TB on some FS.Matronage
S
27

By default, maximum file size is 10MB(If you don't mention explicitly). And if you define explicitly, you can define any value upto GB(even 1000GB). But think, when you open this file, your machine must have an equal amount of RAM. So you have to take this into consideration before choosing file size. An example here

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logging.log
log4j.appender.file.MaxFileSize=100GB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

FileAppender doesn't contain any field for setting file size. But its subclasses RollingFileAppender and DailyFileAppender contains.

Skylar answered 7/8, 2013 at 11:20 Comment(5)
Thanks for your comments. As you mentioned, which property(field) in Log4j FileAppender holds this maximumFileSize value?. Will that datatype of the field holds these big value?.Butterball
Accepting your point as to open file should be supported with RAM size. But, still confused with how this size value is binded within FileAppender.Butterball
I think, you should go for database logging. Actually, FileAppender doesn't contain any such field for size. But their subclasses RollingFileAppender and DailyFileAppender contains. More, you can refer linkSkylar
Is there an inherit negative consequence of size limiting a single log file? It seems like once the limit is reached it would have to be actively managing the size every time the file is written to.Criminal
You CAN open a file that's bigger than your memory if you use a tool that doesn't load the whole file just to show you whatever lines fit on the screen. There are many, but vi does, and emeditor.com/text-editor-features/large-file-support/…Matronage

© 2022 - 2024 — McMap. All rights reserved.