wjinlei / mojito.simplelogging Goto Github PK
View Code? Open in Web Editor NEWA very simple logging library in c#
A very simple logging library in c#
例如,假如你的`maxRollSize="200b"
当你在程序中多次写日志,例如
[Test]
public void TestLogHelper()
{
LogHelper.Debug("Test Message");
LogHelper.Info("Test Message");
LogHelper.Warn("Test Message");
LogHelper.Error("Test Message"); // 假如执行到这里,日志文件的大小超过200个字节了,进行了日志滚动,并创建了新的日志
LogHelper.Fatal("Test Message");
LogHelper.Info("Test Message");
LogHelper.Warn("Test Message");
LogHelper.Error("Test Message"); // 当执行到这里的时候,新的日志文件的大小又超过200字节了,又需要日志滚动,但这这些操作都在1秒内被执行
LogHelper.Fatal("Test Message");
}
此时,滚动的文件名,和之前的文件名一样(秒数一致),因此会移动失败,日志文件中会有记录如下:
2023-11-18 16:34:14 [Error] Test Message
2023-11-18 16:34:14 [Fatal] Test Message
2023-11-18 16:34:14 [Info] Test Message
2023-11-18 16:34:14 [Warn] Test Message
2023-11-18 16:34:14 [Error] Test Message
2023-11-18_16-34-14 RollError 当文件已存在时,无法创建该文件。 at System.IO.FileSystem.MoveFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at Mojito.SimpleLogging.Loggers.FileLogger.RollBackups() in D:\Codes\Mojito.SimpleLogging\Mojito.SimpleLogging\Loggers\FileLogger.cs:line 61
2023-11-18 16:34:14 [Fatal] Test Message
这个问题没什么影响,无法移动,他会把日志继续写入到当前日志文件中,所以可以忽略。
不过我想看能不能有什么优化的方式。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.