日志分割

package mylog

import (
    "github.com/phachon/go-logger"
)

var Logger *go_logger.Logger

func init() {
    Logger = go_logger.NewLogger()
    Logger.Detach("console")
    consoleConfig := &go_logger.ConsoleConfig{
        Format: "%millisecond_format% [%level_string%] [%file%:%line%] %body% ",
    }
    Logger.Attach("console", go_logger.LOGGER_LEVEL_DEBUG, consoleConfig)

    fileConfig := &go_logger.FileConfig{
        Filename: "./callcenter.log", // The file name of the logger output, does not exist automatically
        // If you want to separate separate logs into files, configure LevelFileName parameters.
        DateSlice: "d",                                                             // Cut the document by date, support "Y" (year), "m" (month), "d" (day), "H" (hour), default "no".
        Format:    "%millisecond_format% [%level_string%] [%file%:%line%] %body% ", // JsonFormat is false, logger message written to file format string
    }
    // add output to the file
    Logger.Attach("file", go_logger.LOGGER_LEVEL_DEBUG, fileConfig)
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容