美文网首页
日志分割

日志分割

作者: Feng_Sir | 来源:发表于2018-05-23 09:35 被阅读0次
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)
}

相关文章

网友评论

      本文标题:日志分割

      本文链接:https://www.haomeiwen.com/subject/zpwljftx.html