Quartz.net和Common.Logging - 使用log4net的 [英] Quartz.net and Common.Logging - Using Log4Net

查看:1778
本文介绍了Quartz.net和Common.Logging - 使用log4net的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我已经编辑了窗口服务我的配置文件



<预类=郎咸平的XML prettyprint-覆盖> < configSections>
<节名称=log4net的TYPE =log4net.Config.Log4NetConfigurationSectionHandler,log4net的/>

< sectionGroup名称=通用>
<节名称=记录TYPE =Common.Logging.ConfigurationSectionHandler,Common.Logging/>
< / sectionGroup>
< / configSections>

<&的appSettings GT;
<! - 在这里夺冠的特定服务设置 - >
< /的appSettings>

<普通>
<&记录GT;
< factoryAdapter TYPE =Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4Net>
<精氨酸键=configTypeVALUE =内联/>
<精氨酸键=CONFIGFILEVALUE =C:\sched.log/>
<精氨酸键=级别值=INFO/>
< / factoryAdapter>
< /记录>
< /&常见GT;

<&log4net的GT;
<追加程序名称=EventLogAppenderTYPE =log4net.Appender.EventLogAppender>
<布局类型=log4net.Layout.PatternLayout>
< conversionPattern值=%D [%T]%-5p%L - %M%N/>
< /布局>
< /附加器>
<根和GT;
<电平值=INFO/>
<附加目的地-REF REF =EventLogAppender/>
< /根>
< / log4net的>



我的文件结构如下:



C:\CompanyName - 根目录,所有项目的结果
C:\CompanyName\build\bin - 输出目录的所有项目在我的解决方案结果
/类库的 C:\CompanyName\lib - 如果第三方二进制文件/ dll文件放在



在我的Windows服务项目,我有一个石英引用(在C:\CompanyName\lib文件夹)



我也加入到共同的参考.Logging.Log4net.dll



当我测试我的应用程序,我得到以下错误:




无法加载文件或程序
'Common.Logging,版本= 2.0.0.0,
区域性=中性,
公钥= af08829b84f0328e'或
中的一个其依赖。在位于
集清单定义做
不匹配程序集引用。
(从HRESULT异常:
0x80131040):Common.Logging,
版本2.0.0.0 =文化=中立,
公钥= af08829b84f0328e



解决方案

我想你可能有Common.Logging的版本错误。 Quartz.Net的当前版本使用Common.Logging 1.2版本,而不是2.0。如果您需要使用2.0,无论是尝试重新编译quartz.net与2.0版本的公共记录的或尝试的重定向大会来代替。


I'm using Quartz.net within a windows service. Currently, the trigger is not firing - I'd like to use the logging to find out why.

I have edited my config file for the windows service:

<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>

My file structure is as follows:

C:\CompanyName - root dir for all projects
C:\CompanyName\build\bin - Output directory for all projects / class libraries in my solution
C:\CompanyName\lib - Where 3rd party binaries / dlls are put

In my Windows Service project, I have a reference to Quartz (in the C:\CompanyName\lib folder)

I have also added a reference to Common.Logging.Log4net.dll

When I test my app, I get the following error:

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

解决方案

I think you might have the wrong version of Common.Logging. The current version of Quartz.Net uses the Common.Logging version 1.2, not 2.0. If you need to use 2.0, try either recompiling quartz.net with the 2.0 version of common logging or try redirecting the assembly instead.

这篇关于Quartz.net和Common.Logging - 使用log4net的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆