Git Product home page Git Product logo

Comments (2)

zsummer avatar zsummer commented on August 24, 2024

log4z支持日志分割滚动, 但不支持回滚或者自动清除老日志的功能.

如果你能接受不保留任何老日志的做法, 你可以直接修改log4z.cpp: LogerManager::openLogger 函数下文件名的生成规则, 把含有时间戳和进程号和滚动编号的部分删除, 然后在pLogger->_handle.open(path.c_str(), "ab"); 这行里把"ab"改成"w"就可以了.

如果你的需求是 自动清除一部分更旧的日志但保存部分较新的日志 可以考虑直接写个脚本自动清理.
可以尝试在log4z.cpp: LogerManager::openLogger 中 执行handler.open前写个匹配规则去删除老日志,
https://github.com/zsummer/breeze/blob/cluster/source/common/utls.h 这个头文件的searchFiles是一个支持通配符的跨平台的文件搜索函数, removeFile是删除文件的函数, 不过集成起来可能也略微麻烦一些(要拆部分实现的依赖从utls.h种)
考虑到删除日志是存在较为严重风险的一个方法, 并且可能遇到权限问题, 所以并没有考虑支持日志回滚和自动按规则清除老日志的功能. (还出于尽量保持实现的简洁 和 有那么一点点点想偷懒(偷懒成分绝对不多))

from log4z.

lzx1413 avatar lzx1413 commented on August 24, 2024

好的,我明白了,谢谢

from log4z.

Related Issues (20)

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.