- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
使用 log4net 可以通过更改 app.config 文件在运行时更改日志记录设置。
<add key="log4net.Config.Watch" value="True" />
我的问题很简单:有没有办法为 Serilog 做到这一点?
我已经阅读了有关 LoggingLevelSwitch() 类的内容,但它看起来只能通过代码进行更改。现在当然可以自己对此进行编程,但我正在寻找融入 Serilog 的解决方案。
最佳答案
您不能通过更改 app.config 在运行时更改记录器配置: log4net Documentation
Because the System.Configuration API does not support reloading of the config file the configuration settings cannot be watched using the log4net.Config.XmlConfigurator.ConfigureAndWatch methods. The main advantage of using the System.Configuration APIs to read the configuration data is that it requires less permissions than accessing the configuration file directly.
而且你不能用 Serilog 做到这一点
如您所述,可以在运行时配置日志级别,Source :
var levelSwitch = new LoggingLevelSwitch();
levelSwitch.MinimumLevel = LogEventLevel.Warning;
// configuring the logger using log level switch
var log = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.WriteTo.ColoredConsole()
.CreateLogger();
// and you can switch the log level later on
levelSwitch.MinimumLevel = LogEventLevel.Verbose;
可以看到一些选项here用于更换水槽。
关于c# - Serilog 相当于 log4net.Config.Watch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50715913/
我正在寻找一种为 serilog 提供独立 XML/JSON 配置文件的方法,该文件是从应用程序本身运行的目录中动态加载的。 我正在寻找类似的东西 NLog provides .如 Nlog#Conf
我在我的 aspnet core 应用程序中使用 Serilog 进行日志记录。我需要频繁地将日志事件写入控制台(每秒 300-500 个事件)。我在 docker 容器内运行我的应用程序,并使用 O
是否可以创建一个自动为每条消息添加前缀的记录器? 我通常在每条消息前加上帐户前缀,因为这样更容易阅读,像这样: user1 - did something user2 - did another th
我具有动态更改日志文件路径的功能。但是,当我更改 Consul 中可配置的路径时,它会在两个地方(即旧路径和新路径)写入部分日志。更改日志文件路径应该可以在没有任何服务重启的情况下工作。我们如何存档?
我有很多这样的日志: Log.Information("Submitting order {@order}", order); 此日志通过 RabbitMq -> LogStash -> Elasti
我有很多这样的日志: Log.Information("Submitting order {@order}", order); 此日志通过 RabbitMq -> LogStash -> Elasti
我在服务器端使用 Serilog 为我所有的 .NETCore 服务使用控制台、文件和 Graylog 接收器。我也喜欢在我的 Windows 胖客户端(WPF 应用程序)中使用它。 与 后者我有问题
我正在使用 Serilog.Extensions.Logging 并使用此 outputTemplate 输出到控制台: "{Timestamp:HH:mm} [{Level:u3}] {Messag
Date时间的RollingFile Sink的当前输出如下 2015-04-06 18:40:54.400 +10:00 [Information] Hello World! 无论如何,有没有要消除
我使用 Serilog 作为 .NET 的库,它为文件、控制台和其他地方提供诊断日志记录。 我的问题是我在我的代码中声明了一些日志记录事件,但是在查看 Windows 事件查看器时,分配给我的日志的事
Serilog 的 Azure 表存储接收器是否可以像其他接收器(例如 Elasticsearch 和 Seq)一样通过 app/Web.config 配置,这些接收器可以从配置文件进行配置。 Azu
我正在使用 SeriLog 登录基于 IdentityServer3 的身份验证服务。我刚刚将 serilog.sinks.literate 插件替换为 serilog.sinks.file 插件,以
我使用 Serilog 作为 .NET 的库,它为文件、控制台和其他地方提供诊断日志记录。 我的问题是我在我的代码中声明了一些日志记录事件,但是在查看 Windows 事件查看器时,分配给我的日志的事
我正在尝试安装 serilog,但出现错误 PM> Install-Package Serilog Install-Package : 'Serilog' already has a dependen
从 nlog 转移到 serilog,我希望我的 .NET 框架桌面应用程序在每次运行时重用一个静态命名的日志文件,但在每个新进程中清除文件的内容。可以这样配置serilog吗? This is a
serilog 的可用接收器位于此处:https://github.com/serilog/serilog/wiki/Provided-Sinks 但不包括蔚蓝服务巴士。 目前是否正在努力创建一个?如
我要写 Serilog Warning .NET 集合中的事件,以便它们可以包含在给用户的报告中。我该怎么做 configure the static Log.Logger 写信给类似 static
我尝试在结构化模式下将 JSNLog 与 Serilog 一起使用,如文档中所述: http://jsnlog.com/Documentation/HowTo/StructuredLogging 我在
我正在从 log4net 切换到 Serilog,但错过了我在 log4net 中的一些格式化可能性。我没有找到关于我可以在 outputTemplate 中使用哪些格式化程序的任何文档。有什么方法可
我远不是具有任何 .net 经验的开发人员,但工作中的开发团队希望使用 Serilog 和 serilog-sinks-elasticsearch 将日志推送到我的 ELK 堆栈中。 查看 seril
我是一名优秀的程序员,十分优秀!