当前位置:网站首页>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 does the neural network Internet of things mean? Popular explanation
- Niuke Xiaobai month race 7 F question
- Educational codeforces round 22 E. Army Creation
- Pointnext: review pointnet through improved model training and scaling strategies++
- 1003 emergency (25 points) (PAT class a)
- Regular replacement [JS, regular expression]
- Abc229 summary (connected component count of the longest continuous character graph in the interval)
- Swagger suddenly went crazy
- Some thoughts on whether the judgment point is located in the contour
- Niuke Xiaobai month race 7 e applese's super ability
猜你喜欢

实战模拟│JWT 登录认证

Huawei Nova 10 series supports the application security detection function to build a strong mobile security firewall

Master the use of auto analyze in data warehouse

黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,

HMM hidden Markov model and code implementation

多表操作-外连接查询

BCG 使用之新建向导效果

c# . Net MVC uses Baidu ueditor rich text box to upload files (pictures, videos, etc.)

How is the entered query SQL statement executed?

Multi table operation - external connection query
随机推荐
What are the consequences of closing the read / write channel?
Allure of pytest visual test report
Euler function
Kotlin inheritance
做社交媒体营销应该注意些什么?Shopline卖家的成功秘笈在这里!
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
Add namespace declaration
需求开发思考
Niuke Xiaobai month race 7 who is the divine Archer
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
Optimize if code with policy mode [policy mode]
多表操作-内连接查询
New wizard effect used by BCG
JVM系列之对象的创建
Educational Codeforces Round 22 E. Army Creation
Offset function and windowing function
[graduation season] green ant new fermented grains wine, red mud small stove. If it snows late, can you drink a cup?
Functional interface
Kotlin classes and objects
BCG 使用之CBCGPTabWnd控件(相当于MFC TabControl)