差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
java:log4j2:timeandsizerollingappender [2022/04/10 22:40] tony |
java:log4j2:timeandsizerollingappender [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 31: | 行 31: | ||
appender.logfile.strategy.action.basepath = ./syslog/ | appender.logfile.strategy.action.basepath = ./syslog/ | ||
appender.logfile.strategy.action.maxDepth = 1 | appender.logfile.strategy.action.maxDepth = 1 | ||
- | appender.logfile.strategy.action.IfFileName.type = IfFileName | + | appender.logfile.strategy.action.ifFileName.type = IfFileName |
- | appender.logfile.strategy.action.IfFileName.glob = log.txt* | + | appender.logfile.strategy.action.ifFileName.glob = log.txt* |
- | appender.logfile.strategy.action.IfFileName.IfAccumulatedFileCount.type = IfAccumulatedFileCount | + | appender.logfile.strategy.action.ifFileName.IfAccumulatedFileCount.type = IfAccumulatedFileCount |
- | appender.logfile.strategy.action.IfFileName.IfAccumulatedFileCount.exceeds = 10 | + | appender.logfile.strategy.action.ifFileName.IfAccumulatedFileCount.exceeds = 10 |
</code> | </code> | ||
* **appender.logfile.strategy.action.type**: 設定為Delete,代表要使用Delete Action。 | * **appender.logfile.strategy.action.type**: 設定為Delete,代表要使用Delete Action。 | ||
行 48: | 行 48: | ||
</code> | </code> | ||
===== Multiple Path Conditions ===== | ===== Multiple Path Conditions ===== | ||
- | 前面所提到的pathConditions,是可以支援多個條件的。以前面的例子來說,是設了一組nested的contion,假如改設定成多組會長這個樣子: | + | 前面所提到的pathConditions,是可以支援多個條件的。以前面的例子來說,是設了一組nested的condition,假如改設定成多組會長這個樣子: |
+ | <code properties> | ||
+ | appender.logfile.strategy.action.ifFileName.type = IfFileName | ||
+ | appender.logfile.strategy.action.ifFileName.glob = log.txt* | ||
+ | appender.logfile.strategy.action.ifAccumulatedFileCount.type = IfAccumulatedFileCount | ||
+ | appender.logfile.strategy.action.ifAccumulatedFileCount.exceeds = 10 | ||
+ | </code> | ||
+ | 根據文件描述與目前實驗起來,上面的關係是屬於IfAll的關係。另外記錄一下,目前我們使用的log4j2版本為2.17.2,我發現當設定下面兩組properties時,雖然合理但其實沒有作用。第一組是把key從ifFileName改成IfFileName: | ||
<code properties> | <code properties> | ||
appender.logfile.strategy.action.IfFileName.type = IfFileName | appender.logfile.strategy.action.IfFileName.type = IfFileName | ||
appender.logfile.strategy.action.IfFileName.glob = log.txt* | appender.logfile.strategy.action.IfFileName.glob = log.txt* | ||
- | appender.logfile.strategy.action.IfAccumulatedFileCount.type = IfAccumulatedFileCount | + | appender.logfile.strategy.action.ifAccumulatedFileCount.type = IfAccumulatedFileCount |
- | appender.logfile.strategy.action.IfAccumulatedFileCount.exceeds = 10 | + | appender.logfile.strategy.action.ifAccumulatedFileCount.exceeds = 10 |
</code> | </code> | ||
- | 目前看起來預設情況下上面設定等價於: | + | 第二組是在最上層設定了IfAll是沒有作用的.. |
<code properties> | <code properties> | ||
- | appender.logfile.strategy.action.IfAll.type = IfAll | + | appender.logfile.strategy.action.ifAll.type = IfAll |
- | appender.logfile.strategy.action.IfAll.IfFileName.type = IfFileName | + | appender.logfile.strategy.action.ifAll.ifFileName.type = IfFileName |
- | appender.logfile.strategy.action.IfAll.IfFileName.glob = log.txt* | + | appender.logfile.strategy.action.ifAll.ifFileName.glob = log.txt* |
- | appender.logfile.strategy.action.IfAll.IfAccumulatedFileCount.type = IfAccumulatedFileCount | + | appender.logfile.strategy.action.ifAll.ifAccumulatedFileCount.type = IfAccumulatedFileCount |
- | appender.logfile.strategy.action.IfAll.IfAccumulatedFileCount.exceeds = 10 | + | appender.logfile.strategy.action.ifAll.ifAccumulatedFileCount.exceeds = 10 |
</code> | </code> | ||
- | 就看你個人需求為何了。 | + | 這就不曉得log4j2是否存在某種潛規則了.. |
===== Reference ===== | ===== Reference ===== | ||
* [[https://www.cnblogs.com/yeyang/p/7944899.html|Log4j2中RollingFile的文件滚动更新机制]] | * [[https://www.cnblogs.com/yeyang/p/7944899.html|Log4j2中RollingFile的文件滚动更新机制]] |