golang日志模块测试

package main

import (
"fmt"
"log"
"os"
)

func main(){
logfile,err := os.OpenFile("d:/workspace/golang/test.log",os.O_RDWR|os.O_CREATE|os.O_APPEND,0);
if err!=nil {
fmt.Printf("%s\r\n",err.Error());
os.Exit(-1);
}
defer logfile.Close();
logger := log.New(logfile,"\r\n",log.Ldate|log.Ltime|log.Llongfile);
logger.Println("hello");
logger.Println("oh....");
logger.Fatal("test");
logger.Fatal("test2");
}

这里打开日志文件的时候,同时使用了””os.O_APPEND”这个,这样的话,日志会一直在文件最后面打印出来.

4 thoughts on “golang日志模块测试

  1. Pingback: buy dumps

  2. Pingback: fake watches

  3. Pingback: best cbd reddit

  4. Pingback: used car purchase

Comments are closed.