Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Quartz.Net to write in separate file using NLog

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.

like image 391
Valentyn Vynogradskiy Avatar asked Nov 26 '25 17:11

Valentyn Vynogradskiy


1 Answers

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

like image 198
Dinerdo Avatar answered Nov 29 '25 08:11

Dinerdo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!