最大文件大小 - 在log4j FileAppender中受支持 [英] Maximum File Size - supported in log4j FileAppender

查看:146
本文介绍了最大文件大小 - 在log4j FileAppender中受支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我需要将审计信息存储在文本文件中。我计划使用 Apache Log4j 编写审计信息。



似乎是可靠的选项。但是,我应该可以写审计信息甚至fileSize达到3GB。



log4j 甚至在 GigaBytes ?。



上支持fileSize,什么是 MaximumFileSize 可以在 Log4j 中得到支持。



注意:
我无法使用RollingFileAppender或DailyFileAppender,我需要将信息记录在仅在一个文本文件中,其中一些其他组件正在读取这个文件的内容并执行一些处理。 解决方案默认情况下,最大文件大小为 10MB (如果你没有明确提到)。如果你明确地定义,你可以定义任何值高达 GB (甚至1000GB)。但是想想,当你打开这个文件时,你的机器必须有相同数量的 RAM 。所以你必须在选择文件大小之前考虑这一点。
这里的一个例子

$ p $ #将日志消息直接记录到日志文件
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 不包含设置文件大小的任何字段。但它的子类 RollingFileAppender DailyFileAppender 包含。


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.

解决方案

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.

这篇关于最大文件大小 - 在log4j FileAppender中受支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆