参考

1.博客园: http://www.cnblogs.com/lzrabbit/archive/2012/04/13/2447609.html

2.官网:http://www.cnblogs.com/lzrabbit/archive/2012/04/13/2447609.html

本文主要是记录实施的过程及要点,具体的内容请参考上面的两个地址,写的非常细致。

Job

实现IJob接口,实现void Execute(IJobExecutionContext context)即可,这里可能需要注意的应该是日志。Quart.NET集成了Common.Logging,我在运用时,使用了它的Log4Net扩展。

附加下NuGet安装命令:

install-package Quartz

install-package Common.Logging.Log4Net1211

这里稍微有点坑,Common.Logging.Log4Net有多个版本,每个版本对应的log4net版本是不一致的,并且在App.config(Web.config)中有强制版本的声明,若运行报错一定是没有配置好。我采用Log4Net1211配置如下

 1 <configuration>
 2   <configSections>   
 3     <sectionGroup name="common">
 4       <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
 5     </sectionGroup>
 6   </configSections>
 7 
 8   <common>
 9     <logging>
10       <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211"><!--注意此处的名称要和引用的Nuget包一致,第一次我这边不是1211一直报错,google无数还没解决方案-->
11     ...
12       </factoryAdapter>
13     </logging>
14   </common>
15 
16   <runtime>
17     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">      
18       <dependentAssembly>
19         <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
20         <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.11.0" />
21       </dependentAssembly><!--此处版本也需要一致-->
22     </assemblyBinding>
23   </runtime>
24 </configuration>
View Code

相关文章:

  • 2021-06-08
  • 2022-12-23
  • 2020-10-23
  • 2021-12-03
  • 2021-09-08
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-14
  • 2021-09-14
  • 2021-09-13
  • 2022-03-05
  • 2022-12-23
  • 2021-10-18
  • 2021-08-17
相关资源
相似解决方案