导包

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折腾久了,日志框架还是喜欢这个

log4go折腾的更多相关文章

  1. Go -- log4go日志

    折腾: [已解决]go语言中实现log信息同时输出到文件和控制台(命令行) 期间,已经通过io的MultiWriter搞定了同时输出信息到文件和console,但是不支持level. 所以,再去试试这 ...

  2. ASP.NET Core 折腾笔记二:自己写个完整的Cache缓存类来支持.NET Core

    背景: 1:.NET Core 已经没System.Web,也木有了HttpRuntime.Cache,因此,该空间下Cache也木有了. 2:.NET Core 有新的Memory Cache提供, ...

  3. ASP.NET Core 折腾笔记一

    前言: 在ASP.NET Core 1.0时,曾折腾过一次,后因发现不了System.Data而停止. 更因VS2015提示过期Delete掉VS了,其实主要还是笔记本的硬盘空间吃紧. 快双十一了,本 ...

  4. Gulp探究折腾之路(I)

    前言: gulp是前端开发过程中对代码进行构建的工具,是自动化项目的构建利器:她不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成:使用她,我们不仅可以很愉快的编写代码 ...

  5. 两年来的core折腾之路几点总结,附上nginx启用http2拿来即用的配置

    序:一年多没更新博客园的内容了,core已经发生了翻天覆地的变化,想起2014年这时候,我就开始了从当时还叫k的那套preview都不如的vnext搭建这套系统,陆陆续续它每一次升级,我也相应地折腾, ...

  6. 记录一下折腾webp 的过程

    最近有客户想要处理webp 的动图,情况当然是我们并不能处理webp 格式的图片.这事就交给了我来折腾,一开始想着用瑞士军刀ffmpeg.结果是折腾了差不多一天,前前后后编译了几十次ffmpeg 源码 ...

  7. Hexo折腾记

    如果时间可以静止,我希望就停在此刻. 前言 博主之前也有折腾wordpress和jekyll可对于一个前端er来说,wordpress让人没法尽兴,因为不知道该如何添加自己的代码.而jekyll就太麻 ...

  8. [无聊的事-连载之连开100个VS] 折腾你的骚机吧,骚年们!!!

    [无聊的事-连载之连开100个VS] 折腾你的骚机吧,骚年们!!! 只有8G内存的,用这个:打开你的CMD命令提示符如果只装了Visual Studio 2010,用这条命令,打开50个VSfor / ...

  9. 关于Qt creator 无法使用fcitx输入中文的问题折腾

    环境: 系统ubuntu16.04amd64,qt5.4.2 安装完qt5.4后,在编写代码时,发现无法输入中文,离开qt creator 就立刻正常.原因似乎是qt对fcitx支持. 解决方法我是参 ...

随机推荐

  1. Duplicate Observed Data

    在翻看<重构-改善既有代码的设计>这本经典的书,书中就介绍了一个重构方法--Duplicate Observed Data 复制被监视数据的重构方法,使用这种方法能够使界面和对数据的操作隔 ...

  2. oracle中去掉文本中的换行符、回车符、制表符

    一.特殊符号ascii定义 制表符 chr(9)  换行符 chr(10) 回车符 chr(13) UPDATE tc_car_order set USE_REASON =  REPLACE('USE ...

  3. bzoj3134: [Baltic2013]numbers

    稍微用脑子想一想,要是一个回文数,要么s[i]==s[i+1]要么s[i]==s[i+2]就可以实锤了 所以多开两维表示最近两位选的是什么数就完了 注意前导0 #include<cstdio&g ...

  4. 怎么往mac中finder个人收藏里添加文件夹

    1.打开Finder,点击左上角finder偏好设置 2.选择边栏 3.如果侧栏中没有的文件夹,直接长按文件夹直接拖入.

  5. [Selenium] Grid 介绍

    Selenium Grid 支持分布式测试,使测试人员可在分布式环境中进行测试 一般而言,在面临以下情况时可考虑使用Selenium Grid : 1.测试多个浏览器或单个浏览器多个版本,或测试不同操 ...

  6. vue-resource 设置请求的参数以formData形式以及设置请求的过滤器

    在main.js中添加下面的设置: Vue.http.options.emulateJSON = true;Vue.http.options.headers = {'Content-Type': 'a ...

  7. absolute 和float

    position:absolute与float:left是近亲 包裹性 包裹性换种说法就是让元素inline-block化,例如一个div标签默认宽度是100%显示的,但是一旦被absolute属性缠 ...

  8. python之路,day6-面向对象

    一.面向过程编程 简单的说就是:如果你只是写一些简单的脚本,去做一些一次性任务,用面向过程的方式是极好的,但是如果你要处理的任务比较复杂,且需要不断迭代和维护的,那还是用面向对象最方便了. 二.面向对 ...

  9. 040--JavaScript

    一.JavaScript的两种引入方式 {#1 直接编写#} <script> alert('hello Galileo') </script> {#2 导入文件#} < ...

  10. 看鸟哥的Linux私房菜的一些命令自我总结(三)

    -修改文件创建时间或创建新文件 touch [-acdmt] -a  :仅修改访问时间 -c  :仅修改文件的时间,若该文件不存在则不创建新文件 -d  :后面可以接想要修改的日期而不用当前的日期 - ...