Giter Site home page Giter Site logo

按日切割功能有缺陷 about logrus_mate HOT 6 CLOSED

teroy avatar teroy commented on June 19, 2024
按日切割功能有缺陷

from logrus_mate.

Comments (6)

xujinzheng avatar xujinzheng commented on June 19, 2024

这个hook来自于beego,我做了一下代码的更新,请确认是否可用

https://github.com/astaxie/beego/blob/master/logs/file.go

from logrus_mate.

teroy avatar teroy commented on June 19, 2024
func (w *fileLogWriter) needRotate(size int, day int) bool {
	return (w.MaxLines > 0 && w.maxLinesCurLines >= w.MaxLines) ||
		(w.MaxSize > 0 && w.maxSizeCurSize >= w.MaxSize) ||
		(w.Daily && day != w.dailyOpenDate)

}

还是没解决问题,因为参数day基本上等于记录日志时刻的时间,跟之前的一样。这个代码比较糙,竟然传了一个没用的参数size。

from logrus_mate.

xujinzheng avatar xujinzheng commented on June 19, 2024

你可以给他发一个 PR, 然后我再 Fork 过来😅

from logrus_mate.

xujinzheng avatar xujinzheng commented on June 19, 2024

你可以看看这个hook是否满足你需求,我可以把他兼容过来 https://github.com/rifflock/lfshook

from logrus_mate.

teroy avatar teroy commented on June 19, 2024

提个思路:现在的情况是例如配置了filename="log",则默认记录的日志都到这个log文件中,是否可以改成记录日志的时候文件名带日期,比如今天是20号,则默认使用log.2018-04-20文件,这样子就可以避免不同日期的日志记录到同个文件的情况

from logrus_mate.

xujinzheng avatar xujinzheng commented on June 19, 2024

你可以试试rotatelogs 这个writer(需要更新一下 logrus_mate 的代码)

插件来自于 github.com/lestrrat-go/file-rotatelogs

conf:

import _ "github.com/gogap/logrus_mate/writers/rotatelogs"
out {
    name = rotatelogs
    options {
            path = "logs/access_log.%Y%m%d%H%M"
            //   rotation-time, max-age, link-name, location
     }
}

from logrus_mate.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.