NOVOTS KMS 词汇表 Glossary    联系我们 Contact Us
查询 Search  
   
按类别浏览 Browse by Category
NOVOTS KMS .: 工作心得 .: Quartz.net 及log4net

Quartz.net 及log4net

  1. 简单说明:Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems,更多内容请移步 http://quartznet.sourceforge.net/
  2. 下载地址:http://quartznet.sourceforge.net/download.html (根据需要请自行下载)
  3. 一个示例:本示例仅仅是为了说明Quartz.net作为一个作业调度框架,其使用是多么简单。

具体的Job内容

public class DailyJob : IJob
    {
        public void Execute(JobExecutionContext context)
        {
            //ILog log4net = LogManager.GetLogger("LogFileAppender");
            //log4net.Info(DateTime.Now);
            Console.WriteLine(DateTime.Now);
        }
    }

 

二、log4net

  1. 简单说明:The Apache log4net library is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the excellent Apache log4j™ framework to the Microsoft® .NET runtime,更多内容请自行移步http://logging.apache.org/log4net/
  2. 下载网站:http://logging.apache.org/log4net/download.html
  3. 一个示例:本示例基于配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

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

  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
        <arg key="configType" value="INLINE"/>
      </factoryAdapter>
    </logging>
  </common>

  <log4net>
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
      <param name="File" value="MyQuartzLog.txt" />
      <param name="AppendToFile" value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="LogFileAppender" />
    </root>
  </log4net>

</configuration>

自定义调用

ILog log4net = LogManager.GetLogger("LogFileAppender");
log4net.Info(DateTime.Now);

输出结果

INFO 2012-04-10 04:50:27 – Default Quartz.NET properties loaded from embedded resource file
INFO 2012-04-10 04:50:27 – Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
INFO 2012-04-10 04:50:27 – Quartz Scheduler v.1.0.3.2 created.
INFO 2012-04-10 04:50:27 – RAMJobStore initialized.
INFO 2012-04-10 04:50:27 – Quartz scheduler 'DefaultQuartzScheduler' initialized
INFO 2012-04-10 04:50:27 – Quartz scheduler version: 1.0.3.2
INFO 2012-04-10 04:50:27 – Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
DEBUG2012-04-10 04:50:28 – Producing instance of Job 'DEFAULT.MyFirstDailyJob', class=QuartzNETConsoleApp.DailyJob
DEBUG2012-04-10 04:50:28 – Calling Execute on job DEFAULT.MyFirstDailyJob
INFO 2012-04-10 04:50:28 – 2012-4-10 16:50:28
DEBUG2012-04-10 04:50:28 – Trigger instruction : NoInstruction
DEBUG2012-04-10 04:50:29 – Producing instance of Job 'DEFAULT.MyFirstDailyJob', class=QuartzNETConsoleApp.DailyJob
DEBUG2012-04-10 04:50:29 – Calling Execute on job DEFAULT.MyFirstDailyJob
INFO 2012-04-10 04:50:29 – 2012-4-10 16:50:29
DEBUG2012-04-10 04:50:29 – Trigger instruction : NoInstruction
DEBUG2012-04-10 04:50:30 – Producing instance of Job 'DEFAULT.MyFirstDailyJob', class=QuartzNETConsoleApp.DailyJob
DEBUG2012-04-10 04:50:30 – Calling Execute on job DEFAULT.MyFirstDailyJob

这篇文章对你多有用?

相关文章

article log4net的配置详解
 

(No rating)  8-9-2016    Views: 425   

用户评语

添加评语
当前还没有评语.


.: .: .: .: .:
[ 登陆 ]
北京护航科技有限公司 2006

Novots Technologies Limited