forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
579 B
25 lines
579 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"log"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
Info *log.Logger
|
|
Error *log.Logger
|
|
)
|
|
|
|
func init() {
|
|
//日志输出文件
|
|
file, err := os.OpenFile(fmt.Sprintf("./tomcat8/logs/GWY-%s.log", time.Now().Format("20060102")), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
log.Fatalln("Faild to open error logger file:", err)
|
|
}
|
|
//自定义日志格式
|
|
Info = log.New(io.MultiWriter(file, os.Stderr), "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
|
|
Error = log.New(io.MultiWriter(file, os.Stderr), "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
|
|
}
|
|
|