gpt4 book ai didi

c# - Quartz.net 和 Common.Logging - 使用 Log4Net

转载 作者:行者123 更新时间:2023-11-30 14:43:13 28 4
gpt4 key购买 nike

我在 Windows 服务中使用 Quartz.net。目前,触发器未触发 - 我想使用日志记录找出原因。

我已经为 Windows 服务编辑了我的配置文件:

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>

<appSettings>
<!--specific win service settings here-->
</appSettings>

<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE"/>
<arg key="configFile" value="c:\sched.log"/>
<arg key="level" value="INFO" />
</factoryAdapter>
</logging>
</common>

<log4net>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %l - %m%n" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="EventLogAppender" />
</root>
</log4net>

我的文件结构如下:

C:\CompanyName - 所有项目的根目录
C:\CompanyName\build\bin - 我的解决方案中所有项目/类库的输出目录
C:\CompanyName\lib - 放置第 3 方二进制文件/dll 的地方

在我的 Windows 服务项目中,我引用了 Quartz(在 C:\CompanyName\lib 文件夹中)

我还添加了对 Common.Logging.Log4net.dll 的引用

当我测试我的应用程序时,出现以下错误:

Could not load file or assembly 'Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e

最佳答案

我认为您的 Common.Logging 版本可能有误。当前版本的 Quartz.Net 使用 Common.Logging 版本 1.2,而不是 2.0。如果您需要使用 2.0,请尝试使用 2.0 版本的通用日志记录重新编译 quartz.net 或尝试 redirecting the assembly相反。

关于c# - Quartz.net 和 Common.Logging - 使用 Log4Net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2236772/

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