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

34 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

  12. Pingback: Replica watches

  13. Pingback: Catering Equipment

  14. Pingback: 안전카지노

  15. Pingback: replica tag heuer carrera black

  16. Pingback: KIU-Engineering School

  17. Pingback: porn

  18. Pingback: 안전카지노

  19. Pingback: Research

  20. Pingback: dominoqq

  21. Pingback: 메이저사이트

  22. Pingback: 바카라 사이트 통장

  23. Pingback: satta king

  24. Pingback: 바카라

  25. Pingback: 토토사이트

  26. Pingback: 실시간 바카라 사이트

  27. Pingback: cialis without dr prescription

  28. Pingback: KIU

  29. Pingback: Tate bang 롤 대리 사이트 on Jharkhand for 제드팀 now.

  30. Pingback: review

  31. Pingback: copy G Shock Sale

  32. Pingback: Philadelphia-County-Electric.info

  33. Pingback: buy pfizer viagra in canada

  34. Pingback: 출장녀

Comments are closed.