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

边栏推荐
猜你喜欢

New wizard effect used by BCG

TCP两次挥手,你见过吗?那四次握手呢?

Actual combat simulation │ JWT login authentication

"Only one trip", active recommendation and exploration of community installation and maintenance tasks

English grammar_ Noun - use

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

Stream stream

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

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

Detailed explanation of Audi EDI invoice message
随机推荐
[problem] Druid reports exception SQL injection violation, part always true condition not allow solution
Multi table operation - external connection query
Educational Codeforces Round 22 E. Army Creation
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
PHP pseudo original API docking method
【毕业季】绿蚁新醅酒,红泥小火炉。晚来天欲雪,能饮一杯无?
Several methods of online database migration
1011 World Cup betting (20 points) (pat a)
做社交媒体营销应该注意些什么?Shopline卖家的成功秘笈在这里!
Matrix flip (array simulation)
Dark horse programmer - software testing - 09 stage 2-linux and database -31-43 instructions issued by modifying the file permission letter, - find the link to modify the file, find the file command,
Swagger suddenly went crazy
1005 spell it right (20 points) (pat a)
Informatics Olympiad 1336: [example 3-1] find roots and children
1007 maximum subsequence sum (25 points) (PAT class a)
Anhui Zhong'an online culture and tourism channel launched a series of financial media products of "follow the small editor to visit Anhui"
Kotlin basic data type
Introduction to ACM combination counting
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?
欧拉函数