问题
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>
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?
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>
this was configured from the beggining. The problems strarts when i added Quartz.
回答1:
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.
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:
final – no rules are processed after a final rule matches
来源:https://stackoverflow.com/questions/27525676/configure-quartz-net-to-write-in-separate-file-using-nlog