Golang基礎 日誌管理

2021-10-25 01:32:47 字數 1306 閱讀 3579

所有日誌資訊列印時都帶有時間,且顏色為紅色

每種級別日誌列印都提供了三個函式

日誌擴充套件名為log

func println(v ...inte***ce{})
log.println("列印日誌資訊")
// panicln is equivalent to println() followed by a call to panic().

func panicln(v ...inte***ce{})

log.panicln("列印日誌資訊")
// fatal is equivalent to print() followed by a call to os.exit(1).

func fatal(v ...inte***ce{})

log.fatal("列印日誌資訊")
const (

ldate         = 1 << iota     // the date in the local time zone: 2009/01/23

ltime                         // the time in the local time zone: 01:23:23

lmicroseconds                 // microsecond resolution: 01:23:23.123123. assumes ltime.

llongfile                     // full file name and line number: /a/b/c/d.go:23

lshortfile                    // final file name element and line number: d.go:23. overrides llongfile

lutc                          // if ldate or ltime is set, use utc rather than the local time zone

lstdflags     = ldate | ltime // initial values for the standard logger

)

defer f.close()

logger := log.new(f, "[info]\t", log.ltime)

logger.println("輸出日誌資訊")

golang基礎 tailf日誌元件使用

git上log日誌元件 我們寫個test來測試下這個元件 執行 會在終端輸出如下該檔案的資訊 ps e golang go pro src safly go run safly.go msg msg 92 0800 cst msg 省略我們看看原始碼tailf.go的執行流程 func tailfi...

Linux基礎 日誌管理

在centos 6.x中日誌服務已經由rsyslogd取 代了原先的syslogd服務。rsyslogd日誌服 務更加先進,功能更多。但是不論該服務 的使用,還是日誌檔案的格式其實都是和 syslogd服務相相容的,所以學習起來基本 和syslogd服務一致。基於tcp網路協議傳輸日誌資訊 更安全的...

MySQL 基礎 日誌管理

mysql軟體中的日誌操作 支援的日誌檔案 操作二進位制日誌 1 啟動二進位制日誌 mysqld log bin或log bin d mysqllog binlog 2 檢視二進位制日誌 mysqlbinlog binlog.000001 3 停止二進位制日誌 實現暫時停止二進位制日誌,0代表停止,...