2011-11-13 194 views
1

Java Logging API中的%u &%g(日誌文件模式變量)和它們的使用時間有什麼區別?%u&%g?有什麼區別?

由於

+0

是的,以%g爲單位我該怎麼指定?應該從零開始自動指定嗎?因此我們將標誌旋轉。 – skystar7

回答

1

實測值從的FileHandler API

如果沒有「的溶液%g「字段已被指定,並且文件計數大於 之一,那麼世代號將被添加到生成的文件的末尾 我,一點之後。

因此,例如的「%T/JAVA%g.log」與計數的圖案2將 通常導致登錄到在Solaris寫入 /var/tmp/java0.log文件和/ var/TMP/java1.log而在Windows 95它們 將被典型地寫入到C:\ TEMP \ java0.log和 C:\ TEMP \ java1.log

世代號跟隨序列0,1,2,等等

while%u使文件名唯一,如果多個應用程序試圖登錄到同一個應用程序。

1

甲圖形由一個包括將在運行時被替換下列特殊組分的字符串:

"/" the local pathname separator 
"%t" the system temporary directory 
"%h" the value of the "user.home" system property 
"%g" the generation number to distinguish rotated logs 
"%u" a unique number to resolve conflicts 
"%%" translates to a single percent sign "%"