当前位置:网站首页>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;
}
}

边栏推荐
- 1009 product of polynomials (25 points) (PAT class a)
- abc229 总结(区间最长连续字符 图的联通分量计数)
- 记一次 .NET 某工控数据采集平台 线程数 爆高分析
- Cbcgpprogressdlgctrl progress bar used by BCG
- English grammar_ Noun - use
- 92.(cesium篇)cesium楼栋分层
- TCP waves twice, have you seen it? What about four handshakes?
- On communication bus arbitration mechanism and network flow control from the perspective of real-time application
- Employment prospects of neural network Internet of things application technology [welcome to add]
- Swagger突然发癫
猜你喜欢

TCP waves twice, have you seen it? What about four handshakes?

The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!

Decryption function calculates "task state and lifecycle management" of asynchronous task capability

abc229 总结(区间最长连续字符 图的联通分量计数)

C language - Introduction - Foundation - grammar - process control (VII)

Small hair cat Internet of things platform construction and application model

ACM组合计数入门

上线首月,这家露营地游客好评率高达99.9%!他是怎么做到的?

Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading

c# . Net MVC uses Baidu ueditor rich text box to upload files (pictures, videos, etc.)
随机推荐
矩阵翻转(数组模拟)
1005 spell it right (20 points) (pat a)
Creation of JVM family objects
kotlin 基本使用
What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
Huawei Nova 10 series supports the application security detection function to build a strong mobile security firewall
@transactional滥用导致数据源连接池耗尽问题
Multi table operation - external connection query
What is the application technology of neural network and Internet of things
1006 sign in and sign out (25 points) (PAT class a)
Chrome开发工具:VMxxx文件是什么鬼
Template_ Judging prime_ Square root / six prime method
需求开发思考
求2的n次方
On communication bus arbitration mechanism and network flow control from the perspective of real-time application
kotlin 类和对象
Mysql database basic operation -ddl | dark horse programmer
Crystal optoelectronics: ar-hud products of Chang'an dark blue sl03 are supplied by the company
Regular replacement [JS, regular expression]
记一次 .NET 某工控数据采集平台 线程数 爆高分析