如何在Quartz.Net中从Log4Net切换到NLog? [英] How do I switch from Log4Net to NLog in Quartz.Net?
问题描述
我公司的标准日志记录工具是NLog.我正在尝试介绍Quartz.net,并被问到它是否可以使用NLog代替Log4Net.
My company's standard logging tool is NLog. I'm trying to introduce Quartz.net and was asked if it could use NLog instead of Log4Net.
我知道我可以重新编译以使用NLog,但如果可能的话,我想从配置文件中完成此操作.
I know I can recompile to use NLog, but I'd like to do it from the configuration files if at all possible.
推荐答案
假定您使用的是Quartz.net 1.0.3.您必须添加对以下程序集的引用:
Assuming that you're using Quartz.net 1.0.3. you have to add a reference to the following assemblies:
常用日志记录
Common.Logging.NLog
NLog
Common.Logging
Common.Logging.NLog
NLog
然后,您必须在应用程序的配置文件中添加以下配置:
Then you have to add the following configuration in your application's config file:
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
...
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/NLog.config" />
</factoryAdapter>
</logging>
</common>
</configuration>
请注意,我正在使用外部NLog.config文件.
Note that I am using an external NLog.config file.
注意:
Quartz.net使用Common.Logging版本1.2.
Quartz.net uses Common.Logging version 1.2.
这篇关于如何在Quartz.Net中从Log4Net切换到NLog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!