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”这个,这样的话,日志会一直在文件最后面打印出来.

11 thoughts on “golang日志模块测试

  1. Pingback: w88th

  2. Pingback: 카지노사이트

  3. Pingback: porno

  4. Pingback: https://certyfikowany.edu.pl/

  5. Pingback: qiuqiu99

  6. Pingback: saranapoker

  7. Pingback: แทงบอล

  8. Pingback: Astro Angel

  9. Pingback: cbdque

  10. Pingback: the thao truc tuyen

  11. Pingback: online poster printing

Comments are closed.