当前位置:网站首页>C server log module
C server log module
2022-07-04 20:09:00 【Handsome_ shuai_】
C# Server log module
Configure logs for our server , So we can follow the rules ( For example, according to month / God / Hours This structure prints the log into the corresponding file ), In this way, we divide the log file into Named on mm / DD / yyyy In the generated log file , Prevent a single log file from being too large
Use NuGet In bag Serilog Package to collect logs
<ItemGroup>
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
- Create class library program , Easy to generate DLL For external direct use
- It's packaged twice
public class Logger
{
private static Serilog.Core.Logger coreLogger;
private static Logger warpLogger;
public static Serilog.Core.Logger Instance => coreLogger;
public Logger(string logFileName)
{
coreLogger = new LoggerConfiguration().
WriteTo.Console().
WriteTo.File($"{
logFileName}-.txt", rollingInterval: RollingInterval.Minute).
CreateLogger();
}
public static void Create(string logFileName)
{
warpLogger = (warpLogger == null) ? new Logger(logFileName) : warpLogger;
}
}

边栏推荐
- What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
- HDU 1372 & POJ 2243 Knight moves (breadth first search)
- Dark horse programmer - software testing - stage 08 2-linux and database-23-30-process port related, modify file permissions, obtain port number information, program and process related operations, Li
- Socket programming demo II
- Template_ Large integer subtraction_ Regardless of size
- Regular replacement [JS, regular expression]
- 多表操作-外连接查询
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
- 1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效
- Reflection (I)
猜你喜欢

mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总

公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!

Free soldier

In operation (i.e. included in) usage of SSRs filter

多表操作-内连接查询

做社交媒体营销应该注意些什么?Shopline卖家的成功秘笈在这里!

English语法_名词 - 使用

In the first month of its launch, the tourist praise rate of this campsite was as high as 99.9%! How did he do it?

node_ Exporter deployment

JVM系列之对象的创建
随机推荐
Socket programming demo II
How is the entered query SQL statement executed?
Allure of pytest visual test report
解密函数计算异步任务能力之「任务的状态及生命周期管理」
92. (cesium chapter) cesium building layering
YOLOv5s-ShuffleNetV2
1005 spell it right (20 points) (pat a)
C# 使用StopWatch测量程序运行时间
Detailed explanation of Audi EDI invoice message
【毕业季】绿蚁新醅酒,红泥小火炉。晚来天欲雪,能饮一杯无?
Educational Codeforces Round 22 E. Army Creation
Actual combat simulation │ JWT login authentication
HDU 1097 A hard puzzle
Add namespace declaration
HMM隐马尔可夫模型最详细讲解与代码实现
Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
Educational codeforces round 22 E. Army Creation
In the first month of its launch, the tourist praise rate of this campsite was as high as 99.9%! How did he do it?
HDU 6440 2018中国大学生程序设计网络选拔赛
Euler function