go中的日志库-log4go

"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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。