go log

package main

import (
	"log"
	"os"
)

var (
    Info *log.Logger
    Warning *log.Logger
    Error * log.Logger
)
func main(){
	logFile,error:=os.OpenFile("./log.log",os.O_CREATE|os.O_WRONLY|os.O_APPEND,0644)
  if error!=nil {
    log.Fatalln("打开日志文件失败")
  }
  defer logFile.Close()
  Info = log.New(logFile,"Info:",log.Ldate | log.Ltime | log.Llongfile)
  Warning = log.New(logFile,"Warning:",log.Ldate | log.Ltime | log.Llongfile)
  Error = log.New(logFile,"Error:",log.Ldate | log.Ltime | log.Llongfile)
  Info.Output(1,"这是info")
  Warning.Output(1,"warning")
  Error.Output(1,"error")

}

  

上一篇:spring – liquibase-hibernate5不能使用liquibase-maven-plugin


下一篇:python logging 的使用