log
记录日志可以添加 前缀,后缀,时间等信息
日志记录到文件
package main
import (
"log"
"os"
)
func main() {
file,err := os.Create("test.log")
if err != nil {
log.Fatalln("fail to create test.log file!")
}
defer file.Close()
logger := log.New(file, "info:", log.LstdFlags|log.Lshortfile)
logger.Println("this is phpddt.com testing")//info:2015/11/15 01:11:48 test.go:17: this is phpddt.com testing
}
网友评论