You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Log4J2 Properties文件中配置minSize=0

How to configure Log4J2's OnStartupTriggeringPolicy minSize=0 in Properties files

Got it, let's walk through this! When switching from Log4J2's XML/JSON-style config to Properties files, you just need to adapt to the flat, dot-separated structure that Properties uses. Here's exactly how to set minSize to 0 for OnStartupTriggeringPolicy:

In Log4J2 Properties config, you define components by their type and nest them under parent components using dots. For an OnStartupTriggeringPolicy attached to a RollingFileAppender, your config will follow this pattern:

# Replace <your-appender-name> with your actual appender's name (e.g., "rollingFile")
appender.<your-appender-name>.policy.type = OnStartupTriggeringPolicy
appender.<your-appender-name>.policy.minSize = 0

Example with a concrete appender name

If your appender is named myAppLog, the working config would look like this:

appender.myAppLog.policy.type = OnStartupTriggeringPolicy
appender.myAppLog.policy.minSize = 0

This tells Log4J2 to create an OnStartupTriggeringPolicy instance for your appender, with the minimum file size threshold set to 0 bytes. That means the policy will trigger a log rollover on application startup no matter how small the current log file is.

内容的提问来源于stack exchange,提问作者Configueroa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 17:30:43