Comments (7)
应该不会,这个机器还有其他项目在运行,用的别的日志库,都是正常的。 我先改分割模式试试吧。
from slog.
@craterone 看我加了个测试,没有发现有问题呢?内容和文件差了一天吗?
写日志比较密集的话可能会出现几个边界数据问题的,这个是没法避免的。
from slog.
对,差了一天。日志数据量不大,使用的版本是 slog v0.5.5
h1 := handler.MustRotateFile(G_Config.LogFilePath, rotatefile.EveryDay,
handler.WithLogLevels(slog.AllLevels),
handler.WithBuffSize(0),
handler.WithBackupNum(10),
handler.WithMaxSize(1<<30), // 1GB
)
h1.SetFormatter(f)
G_Logger = slog.NewWithHandlers(h1)
比如使用 slog 生成的日志 2024-03-24, 日志包含的大部分 2024-03-23的日志,和几行 2024-03-24凌晨的日志
我看一下其他库,感觉是逻辑不太一样,比如 2024-03-25 当天,其他库会写日志的时候,会直接写在 2024-03-25.log 文件; 而slog 会写在 xx.log 里,然后rename 成 2024-03-25.log 。我猜会不会是,这个rename的时间点如果迟了,就会迟一天了
from slog.
@craterone 你看看这个日志文件的创建时间呢?
可以选择分割模式: rename 或者 create(会直接写
name-DATETIME.log
)
from slog.
打不出来创建时间,只有最后修改时间
signal.log.20240324
File: ‘signal.log.20240324’
Size: 264960 Blocks: 528 IO Block: 4096 regular file
Device: fd11h/64785d Inode: 6689045 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-03-25 09:44:46.941377348 +0800
Modify: 2024-03-24 00:00:20.796371637 +0800
Change: 2024-03-24 00:00:20.798371631 +0800
可以选择分割模式: rename 或者 create(会直接写
name-DATETIME.log
)
如何选择分割模式,我看了一下文档没找到
from slog.
handler.WithRotateMode(rotatefile.ModeCreate),
设置分割模式。
确认机器上时区啥的没问题吗? 😄
from slog.
找到问题了,使用的当前时间生成文件名称,如果刚好过了0点切割,生成的文件名称就错了。
from slog.
Related Issues (20)
- record中的Time time.Time HOT 8
- 能在 golang 1.10 版本下使用吗 HOT 1
- Setting channel name cross multiple loggers HOT 3
- Level handling is non-obvious HOT 3
- slog 运行时不会限制备份数量和压缩备份文件 HOT 3
- 在Console模式下也支持类似withfield功能 HOT 6
- syslog 能否增加 facility 支持? HOT 7
- [Bug] RotateTime.level() HOT 2
- Run rotate
- gorm support HOT 2
- 内建的 rotate 机制有多个bug HOT 2
- 需要一个动态设置日志级别的接口
- 按日期滚动 如果当天时间节点的日志文件已存在 不会append 会直接替换 HOT 1
- 自定义模板报 invalid memory address or nil pointer dereference HOT 4
- NewFlushCloseHandler bytes.Buffer does not implement handler.FlushCloseWriter HOT 1
- syslog severity mapping problem
- Isn't `slog.Fatal()` meant to call `os.Exit(1)`? HOT 4
- slog: failed to handle log, error: write ./logs/info.log: file already closed HOT 2
- 设置日志颜色,支持只设置 tag,不设置日志内容颜色 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slog.