gpt4 book ai didi

Log4net EventLogAppender 日志事件 ID

转载 作者:行者123 更新时间:2023-12-02 04:16:18 24 4
gpt4 key购买 nike

有没有办法将每条消息指定的 eventid 记录到 Windows 事件日志中?我正在使用 log4net v 1.2.10。

最佳答案

根据我在 EventLogAppender 源代码中看到的内容,以下内容应该可以解决问题:

log4net.ThreadContext.Properties["EventID"] = 5;

只需在编写日志消息之前调用此函数即可(如果您没有为所有消息设置它,则应再次从属性中删除“EventID”。

注意,属性键区分大小写。

关于Log4net EventLogAppender 日志事件 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2290102/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com