2

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.

walen
  • 7,103
  • 2
  • 37
  • 58
  • usefull http://stackoverflow.com/questions/6569936/how-do-i-switch-from-log4net-to-nlog-in-quartz-net/6570161#6570161? – Neel Dec 17 '14 at 12:34
  • As @Neel points out you need to configure Common logging to redirect its logging to NLog. – Peter Dec 17 '14 at 12:48
  • The first code snippet is that located in NLog.Config or web/app.config? you have configured Common.Logging to use NLog.Config. – Peter Dec 17 '14 at 13:25
  • Yes, Nlog.Config is separate configuration for my project. We keep all nlog config there – Valentyn Vynogradskiy Dec 17 '14 at 13:27

1 Answers1

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

Dinerdo
  • 560
  • 7
  • 27