Quartz.net 和 Common.Logging - 使用 Log4Net

2023-12-01

我在 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:\公司名称- 所有项目的根目录
C:\公司名称\build\bin- 我的解决方案中所有项目/类库的输出目录
C:\公司名称\lib- 第 3 方二进制文件/dll 的放置位置

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

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

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

无法加载文件或程序集 'Common.Logging,版本=2.0.0.0, 文化=中立, PublicKeyToken=af08829b84f0328e' 或 它的依赖项之一。位于的 程序集的清单定义确实 与装配参考不匹配。 (HRESULT 的异常: 0x80131040)":"通用.日志记录, 版本=2.0.0.0,文化=中立, 公钥令牌=af08829b84f0328e


我认为您可能使用了错误版本的 Common.Logging。当前版本的 Quartz.Net 使用 Common.Logging 版本 1.2,而不是 2.0。如果您需要使用 2.0,请尝试使用 2.0 版本的通用日志记录重新编译quartz.net,或者尝试重定向程序集反而。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Quartz.net 和 Common.Logging - 使用 Log4Net 的相关文章

随机推荐