当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢
Several methods of online database migration
The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
Neural network IOT platform construction (IOT platform construction practical tutorial)
What are the consequences of closing the read / write channel?
Mysql database basic operation -ddl | dark horse programmer
Actual combat simulation │ JWT login authentication
Key rendering paths for performance optimization
Creation of JVM family objects
Development and construction of DFI ecological NFT mobile mining system
Some thoughts on whether the judgment point is located in the contour
随机推荐
Chrome开发工具:VMxxx文件是什么鬼
Huawei Nova 10 series supports the application security detection function to build a strong mobile security firewall
Siemens HMI download prompts lack of panel image solution
"Only one trip", active recommendation and exploration of community installation and maintenance tasks
1009 product of polynomials (25 points) (PAT class a)
公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
水晶光电:长安深蓝SL03的AR-HUD产品由公司供应
On communication bus arbitration mechanism and network flow control from the perspective of real-time application
kotlin 继承
node_ Exporter deployment
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
Actual combat simulation │ JWT login authentication
C language - Introduction - Foundation - grammar - process control (VII)
@Data source connection pool exhaustion caused by transactional abuse
c# . Net MVC uses Baidu ueditor rich text box to upload files (pictures, videos, etc.)
Niuke Xiaobai month race 7 F question
上线首月,这家露营地游客好评率高达99.9%!他是怎么做到的?
YOLOv5s-ShuffleNetV2
Prometheus installation
TCP两次挥手,你见过吗?那四次握手呢?