Serilog,即使日志文件无法打开没有错误/创建

问题描述 投票:1回答:1

我期待到Serilog作为替代log4net的(我有哪里的log4net停止,没有明确的方式记录从此一蹶不振的问题)。这是C#中,主要的WinForms。

首先,这里是在app.config设置:

<add key="serilog:write-to:RollingFile.pathFormat" value="q:\SomeApp-%COMPUTERNAME%-log-{Date}.txt" />
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}" />
<add key="serilog:write-to:File.rollOnFileSizeLimit" value="true" />
<add key="serilog:write-to:File.fileSizeLimitBytes" value="10485760" />
<add key="serilog:write-to:File.retainedFileCountLimit" value="10" />
<add key="serilog:minimum-level" value="Information" />

在C#应用程序,我创造这样的记录:

Log.Logger = new LoggerConfiguration()
                .ReadFrom.AppSettings()
                .CreateLogger();

问:CreateLogger没有给出问题的迹象,甚至当我在指定的路径无效“serilog:写于:RollingFile.pathFormat”上面,但当然没有得到记录。

日志记录是至关重要的,因此,如果它不工作,我需要了解它。我如何知道?

c# winforms log4net serilog
1个回答
0
投票

Serilog,像最典型的记录器不会妨碍默认应用进展。有一个.Audit.To配置机制,可以把它做到这一点,但它不太可能,这将是你的答案。

在一般情况下,接线Serilog's SelfLog在故障安全接收器是如何highlightint在日志系统故障,最好的管理。

旁白:这似乎也是你混合RollingFile和文件配置 - File已经取代了前者那么其推荐使用仅是新系统。

© www.soinside.com 2019 - 2024. All rights reserved.