基本用法
- 创建 test.go
package main import "github.com/golang/glog" func main() { glog.Info("Testing glog.") glog.Flush() }
- 运行
go run test.go
- 检查 /tmp 目录,出现了两个新的文件
ll /tmp/ total 4 -rw-r--r--. 1 root root 264 Jan 18 13:29 test.{host}.{user}.log.INFO.{date} lrwxrwxrwx. 1 root root 64 Jan 18 13:29 test.INFO -> test.{host}.{user}.log.INFO.{date}
- 查看 test.INFO 的内容
Log file created at: {date} Running on machine: {host} Binary: Built with gc go1.9 for linux/amd64 Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg I0118 13:29:20.878522 16625 test.go:6] Testing glog.
log 等级
基本的 log 等级分为