配置Quartz.Net以使用NLog写入单独的文件 [英] Configure Quartz.Net to write in separate file using NLog

查看:663
本文介绍了配置Quartz.Net以使用NLog写入单独的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的nlog配置.我想要实现的是将Quartz日志保存在单独的文件中.但是检查日志文件夹,我只找到调度程序日志文件.

This is my config for nlog. What i'm trying to achieve is to have Quartz logs in separate file. But checking the logs folder i find only scheduler log file.

  <targets>
    <target xsi:type="File" name="f" fileName="${basedir}/logs/log-${shortdate}.log.json" layout="${json}" /> 
    <target xsi:type="File" name="scheduler" fileName="${basedir}/logs/log-${shortdate}.scheduler.log" layout="${message}" /> 
    <target xsi:type="Console" name="console" layout="${longdate} ${uppercase:${level}} ${message}" /> 
    </targets>
  <rules>
    <logger name="Quartz*" minlevel="Trace" writeTo="scheduler" final="true"/>
    <logger name="*" minlevel="Info" writeTo="console" />
    <logger name="*" minlevel="Trace" writeTo="f" />
  </rules>
</nlog>

注意:我也尝试过Quartz.*并更改顺序.但这无济于事.

Note: I also tried Quartz.* and change the order. But it dosen't help me.

我是否需要任何其他配置才能使其正常工作?

Do i need any additional configuration to make it work?

更新1:抱歉造成误会.使用Common.Logging可以很好地进行日志记录.为Quartz创建的Andlogging文件也显示正确的日志.问题是要同时拥有这两个对象,在我的情况下,由于某种原因,石英规则会阻止创建主对象.

Update 1: Sorry for misunderstanding. Logging itself working fine with Common.Logging. Andlogging file for Quartz that created also shows correct log. The problem is to have both of them, coz in my case for some reason quartz rule prevent creation of main one.

<common>
<logging>
  <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog31">
    <arg key="configType" value="FILE" />
    <arg key="configFile" value="~/NLog.config" />
  </factoryAdapter>
</logging>

这是从一开始就配置的.当我添加Quartz时,问题就成问题了.

this was configured from the beggining. The problems strarts when i added Quartz.

推荐答案

记录本身可以与Common.Logging一起正常工作.的Andlogging文件 创建的石英也显示正确的日志.问题是要 他们两个,因为我的原因,因为某种原因,石英法则阻止了 创建主要的一个.

Logging itself working fine with Common.Logging. Andlogging file for Quartz that created also shows correct log. The problem is to have both of them, coz in my case for some reason quartz rule prevent creation of main one.

从您的第一个记录器规则中取出"final = true",以便它继续处理其他规则.我知道这很旧,但是可以解决您的问题:

Take "final=true" out of your first logger rule so that it continues to process the other rules. I know this is old, but that would solve your problem:

最终-最终规则匹配后将不处理任何规则

这篇关于配置Quartz.Net以使用NLog写入单独的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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