• log4go折腾


    导包 

    go get -u github.com/alecthomas/log4go
    log4go.xml配置
    <logging>
        <filter enabled="true">
            <tag>stdout</tag>
            <type>console</type>
            <!-- level is (:?FINEST|FINE|DEBUG|TRACE|INFO|WARNING|ERROR) -->
            <level>DEBUG</level>
        </filter>
        <filter enabled="true">
            <tag>file</tag>
            <type>file</type>
            <level>INFO</level>
            <property name="filename">test_client.log</property>
            <!--
               %T - Time (15:04:05 MST)
               %t - Time (15:04)
               %D - Date (2006/01/02)
               %d - Date (01/02/06)
               %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT)
               %S - Source
               %M - Message
               It ignores unknown format strings (and removes them)
               Recommended: "[%D %T] [%L] (%S) %M"
            -->
            <property name="format">[%D %T] [%L] (%S) %M</property>
            <property name="rotate">false</property> <!-- true enables log rotation, otherwise append -->
            <property name="maxsize">10M</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">false
            </property> <!-- Automatically rotates when a log message is written after midnight -->
        </filter>
        <filter enabled="false">
            <tag>xmllog</tag>
            <type>xml</type>
            <level>INFO</level>
            <property name="filename">trace.xml</property>
            <property name="rotate">true</property> <!-- true enables log rotation, otherwise append -->
            <property name="maxsize">100M</property> <!-- d+[KMG]? Suffixes are in terms of 2**10 -->
            <property name="maxrecords">6K</property> <!-- d+[KMG]? Suffixes are in terms of thousands -->
            <property name="daily">false
            </property> <!-- Automatically rotates when a log message is written after midnight -->
        </filter>
        <filter enabled="false"><!-- enabled=false means this logger won't actually be created -->
            <tag>donotopen</tag>
            <type>socket</type>
            <level>FINEST</level>
            <property name="endpoint">192.168.1.255:12124</property> <!-- recommend UDP broadcast -->
            <property name="protocol">udp</property> <!-- tcp or udp -->
        </filter>
    </logging>

    加载log4go

    func init() {
        log.LoadConfiguration("log4go.xml")
    }

    写日志

    //导包 log "github.com/alecthomas/log4go"
    log.Info("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    
    log.Debug("111111111111111111111111111")

    java折腾久了,日志框架还是喜欢这个

    有追求,才有动力!

    向每一个软件工程师致敬!

    by wujf

    mail:921252375@qq.com

  • 相关阅读:
    Java 线程
    杂记
    字符流分类详细介绍和各种字符流类介绍与使用 字符集
    内部类 与 匿名内部类
    Java IO流学习总结
    java的集合框架
    jquery 只能投票一次
    C# 简易版的计算器程序
    常用DBHelper类
    jQuery异步提交
  • 原文地址:https://www.cnblogs.com/wujf/p/10696017.html
Copyright © 2020-2023  润新知