Quartz.Net 配置模板范例

 

 

1.App.config

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3.   <configSections>
  4.     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  5.     <sectionGroup name="common">
  6.       <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
  7.     </sectionGroup>
  8.   </configSections>
  9.   <common>
  10.     <logging>
  11.       <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211">
  12.         <arg key="configType" value="INLINE" />
  13.       </factoryAdapter>
  14.     </logging>
  15.   </common>
  16.   <log4net>
  17.     <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
  18.       <layout type="log4net.Layout.PatternLayout">
  19.         <conversionPattern value="%d [%t] %-5p %l - %m%n %property{ServiceType}" />
  20.       </layout>
  21.     </appender>
  22.     <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
  23.       <layout type="log4net.Layout.PatternLayout">
  24.         <conversionPattern value="%d [%t] %-5p %l - %m%n" />
  25.       </layout>
  26.     </appender>
  27.     <appender name="RollingFileAppenderAll" type="log4net.Appender.RollingFileAppender">
  28.       <param name="File" value="Log/alllLog.txt" />
  29.       <appendToFile value="true" />
  30.  
  31.       <!--Make the rolling file name with the date and size-->
  32.       <rollingStyle value="Composite" />
  33.       <datePattern value="yyyyMM" />
  34.       <maxSizeRollBackups value="100" />
  35.       <maximumFileSize value="2MB" />
  36.  
  37.       <PreserveLogFileNameExtension value="true" />
  38.       <staticLogFileName value="false" />
  39.       <layout type="log4net.Layout.PatternLayout">
  40.         <param name="ConversionPattern" value="%d %-5p %m%n" />
  41.       </layout>
  42.     </appender>
  43.     <root>
  44.       <level value="INFO" />
  45.       <appender-ref ref="ConsoleAppender" />
  46.       <appender-ref ref="RollingFileAppenderAll" />
  47.     </root>
  48.   </log4net>
  49.   <appSettings>
  50.     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  51.   </appSettings>
  52.   <system.web>
  53.     <compilation debug="true" />
  54.   </system.web>
  55.   <!-- 部署服务库项目时,必须将配置文件的内容添加到
  56.   主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
  57.   <runtime>
  58.     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  59.       <dependentAssembly>
  60.         <assemblyIdentity name="Common.Logging.Core" publicKeyToken="af08829b84f0328e" culture="neutral" />
  61.         <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
  62.       </dependentAssembly>
  63.       <dependentAssembly>
  64.         <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
  65.         <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
  66.       </dependentAssembly>
  67.     </assemblyBinding>
  68.   </runtime>
  69. <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>

 

2.quartz_jobs.xml

 

  1. <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
  2.   <processing-directives>
  3.     <overwrite-existing-data>true</overwrite-existing-data>
  4.   </processing-directives>
  5.   <schedule>
  6.  
  7.     <!--清除日志文件-->
  8.     <job>
  9.       <name>RemoveLogFileEveryDay</name>
  10.       <group>InnerBusiness</group>
  11.       <description>每天清除两周以前的日志文件</description>
  12.       <job-type>NS.RemoveLogFileEveryDay, NS</job-type>
  13.       <durable>false</durable>
  14.       <recover>true</recover>
  15.     </job>
  16.     <trigger>
  17.       <cron>
  18.         <name>RemoveLogFileEveryDayTrigger</name>
  19.         <group>RemoveLogFileEveryDayTrigger</group>
  20.         <description>每天23:00点执行一次</description>
  21.         <job-name>RemoveLogFileEveryDay</job-name>
  22.         <job-group>InnerBusiness</job-group>
  23.         <misfire-instruction>DoNothing</misfire-instruction>
  24.         <cron-expression>0 0 23 * * ?</cron-expression>
  25.       </cron>
  26.     </trigger>
  27.  
  28.   </schedule>
  29. </job-scheduling-data>

 

 

3.quartz.config

  1. #============================================================================
  2. # Configure Main Scheduler Properties
  3. #============================================================================
  4. org.quartz.scheduler.instanceName = TestScheduler
  5. org.quartz.scheduler.instanceId = AUTO
  6.  
  7. #============================================================================
  8. # Configure ThreadPool
  9. #============================================================================
  10. org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
  11. org.quartz.threadPool.threadCount = 20
  12. org.quartz.threadPool.threadPriority = 5
  13.  
  14. #============================================================================
  15. # Configure JobStore
  16. #============================================================================
  17. org.quartz.jobStore.misfireThreshold = 60000
  18. org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
  19.  
  20. #--------------------------------*************plugin配置------------------------------------
  21. # job initialization plugin handles our xml reading, without it defaults are used
  22. quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz
  23. quartz.plugin.xml.fileNames = ~/quartz_jobs.xml
  24.  
  25. # export this server to remoting context
  26. quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
  27. quartz.scheduler.exporter.port = 2015
  28. quartz.scheduler.exporter.bindName = QuartzScheduler
  29. quartz.scheduler.exporter.channelType = tcp
  30. quartz.scheduler.exporter.channelName = httpQuartz

 

 

参考: http://www.cnblogs.com/philzhou/archive/2012/11/16/2772533.html

posted @ 2015-06-17 13:46  _DN  阅读(375)  评论(0编辑  收藏  举报