"github.com/thinkboy/log4go"不支持毫秒,需要修改下源码
在pattlog.go文件中的
func FormatLogRecord(format string, rec *LogRecord) string
secm := rec.Created.Format("2006-01-02 15:04:05.000")
updated := &formatCacheType{
LastUpdateSeconds: secs,
shortTime: fmt.Sprintf("%02d:%02d", hour, minute),
shortDate: fmt.Sprintf("%02d/%02d/%02d", month, day, year%100),
longTime: fmt.Sprintf("%s %s", secm, zone),
longDate: fmt.Sprintf("%04d/%02d/%02d", year, month, day),
}
1.可以在.xml中间中配置多个filter,每个filter都会在自己的目标文件上打印日志,并不冲突,debug文件的级别最低
2.常用参数解析
<filter enabled="true"> 为true的时候才生效
<tag>debug_file</tag>
<type>file</type>
<level>DEBUG</level>
<property name="filename">log/comet_debug.log</property>
<property name="format">[%D %T] [%L] [%S] %M</property>
<property name="rotate">true</property> <!-- true enables log rotation, otherwise append -->
<property name="maxsize">0M</property> <!-- \d+[KMG]? Suffixes are in terms of 2**10 -->
<property name="maxlines">0K</property> <!-- \d+[KMG]? Suffixes are in terms of thousands -->
<property name="daily">true</property> <!-- Automatically rotates when a log message is written after midnight -->
</filter>