2011-11-13 195 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 "%"