24

I am using Quartz.NET for scheduling some custom tasks in our application. Everything works fine except that it logs about twenty debug entries in one second.

I don't know how to turn off the debug logging. Any help would be really appreciated as I have been trying to lookup in the net with no luck.

The debug entries look like the below

DEBUG 2009-05-12 03:24:14,000 8612670ms StdRowLockSemaphore    ObtainLock         - Lock 'TRIGGER_ACCESS' is desired by: SchedulerFactory_QuartzSchedulerThread
DEBUG 2009-05-12 03:24:14,029 8612699ms StdRowLockSemaphore    ExecuteSQL         - Lock 'TRIGGER_ACCESS' is being obtained: SchedulerFactory_QuartzSchedulerThread
DEBUG 2009-05-12 03:24:14,029 8612699ms StdRowLockSemaphore    ObtainLock         - Lock 'TRIGGER_ACCESS' given to: SchedulerFactory_QuartzSchedulerThread
DEBUG 2009-05-12 03:24:14,034 8612704ms StdRowLockSemaphore    ReleaseLock        - Lock 'TRIGGER_ACCESS' returned by: SchedulerFactory_QuartzSchedulerThread
DEBUG 2009-05-12 03:24:14,035 8612705ms StdRowLockSemaphore    ObtainLock         - Lock 'TRIGGER_ACCESS' is desired by: SchedulerFactory_QuartzSchedulerThread
DEBUG 2009-05-12 03:24:14,035 8612705ms JobRunShell            Run                - Calling Execute on job DEFAULT.ProcessIncomingMTRJob
Mariano Desanze
  • 7,847
  • 7
  • 46
  • 67
Ganesh
  • 251
  • 1
  • 2
  • 5

6 Answers6

27

Rytmis' answer is great if you want to reduce all your logging which goes through the Common Logging Infrastructure.

But if you have more code logging through Common Logging, and you just want to reduce the ammount of logging from Quartz (and not from the rest of the your code), what I recomend is this:

In the log4net config xml (app.config usually) you probably already have something like this:

    <root>
        <level value="ALL" />
        <appender-ref ... />
        ...
    </root>

Leave that as it is. And after that (or anywhere inside the <log4net> config section) just add this:

    <logger name="Quartz">
        <level value="ERROR" />
    </logger>

This <logger> section will configure all the loggers with the namespace "Quartz". So in this example Quartz will be logging with level ERROR while the rest of my app will log with level ALL.

Community
  • 1
  • 1
Mariano Desanze
  • 7,847
  • 7
  • 46
  • 67
17

If any one needs to do this in NLog just add the following as the top most rule in NLog.Config

<!-- Disable Quartz info logging -->
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />

Note that this will still let Warn, Error, Fatal go to the other loggers if you don't want that change maxlevel="Info" to maxlevel="Fatal"

Peter
  • 37,042
  • 39
  • 142
  • 198
7

Quartz.net uses Common.Logging, so something like this in your App.config/Web.config:

<configSections>
    <sectionGroup name="common">
        <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
</configSections>

<common>
    <logging>
        <factoryAdapter type="Common.Logging.Simple.**youradapterhere**, Common.Logging">
            <arg key="level" value="ERROR" />
        </factoryAdapter>
    </logging>
</common>

Be sure to change the youradapterhere to the actual logging adapter you're using, or NoOpLoggerFactoryAdapter if you want to disable logging entirely.


** Edit: ** Based on Ganesh's comment:

<sectionGroup name="common"> 
    <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/> 
</sectionGroup> 
<common>  
    <logging>  
        <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">  
            <arg key="configType" value="INLINE"/>  
            <arg key="configFile" value="filename"/>  
            <arg key="level" value="ERROR" /> <!-- add this line here -->
        </factoryAdapter>  
    </logging> 
</common>

** Edit 2: **

For the benefits of those who don't want to read the comments, the log level was actually set in the log4net root config:

<log4net>
    <root>
        <level value="DEBUG" /> <!-- This is the value that needed changing -->
        <appender-ref ref="Console" />
        <appender-ref ref="RollingFile" />
    </root>
</log4net>
Rytmis
  • 31,467
  • 8
  • 60
  • 69
  • We are already using the Common.Logging in our ASP .Net application. The entry in the web.config looks as below. Can you help me out as to where do i add the entry you suggested
    – Ganesh May 18 '09 at 11:41
  • I edited my answer with your config and added the relevant line. – Rytmis May 18 '09 at 12:12
  • We are also logging info from the component which Quartz .net invokes as a scheduled job. Is it possible to specify multiple values in the key Will this be possible Thanks for all your help – Ganesh May 18 '09 at 13:31
  • 1
    Log4Net docs say the following: "A log request of level L in a logger with (either assigned or inherited, whichever is appropriate) level K, is enabled if L >= K. This rule is at the heart of log4net. It assumes that levels are ordered. For the standard levels, we have DEBUG < INFO < WARN < ERROR < FATAL." The way I interpret that is, if you set loglevel to INFO, you will also get all messages from levels WARN, ERROR and FATAL. So you should replace ERROR with INFO in my example. – Rytmis May 18 '09 at 19:23
  • As per your advice i added the specified line to the web.config at the recommended position, but Quartz .Net is still printing the DEBUG log messages. The line I added is Any idea as to why it is not working? – Ganesh May 19 '09 at 06:59
  • Do you have any appender-specific configurations that would have a setting in the config file? – Rytmis May 19 '09 at 07:30
  • The root tag, configuration is and I changed it to Quartz.Net has stopped the Debug logging but it still logs, minimum of about 5 Info entries per second. Is there a way to control the logging from the jobs.xml file which configures the triggers and schedule for Quartz .Net? – Ganesh May 19 '09 at 08:10
  • Not that I know of. Taking a quick peek at some of the sources, it looks like the logging is configured by level, not by action, so I suspect your best bet is just specifying a different log level. – Rytmis May 19 '09 at 08:52
6

In my case for turn off Quartz.net logging I just add this property in my C# code where configuring Scheduler.

LogProvider.IsDisabled = true;

in total view :

public static async void Start()
    {

        LogProvider.IsDisabled = true;
        ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
        IScheduler scheduler = await schedulerFactory.GetScheduler();
        await scheduler.Start();

        IJobDetail job = JobBuilder.Create<SendNotificationJob>().Build();

        ITrigger trigger = TriggerBuilder.Create()

            .WithDailyTimeIntervalSchedule
              (s =>
                 s.WithIntervalInSeconds(1)
                .OnEveryDay()
                .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0))
              )
            .Build();

        await scheduler.ScheduleJob(job, trigger);
    }

and do not forget to add this using :

using Quartz.Logging;
xwpedram
  • 467
  • 1
  • 8
  • 20
2

For those that do not want Quartz logging at all (i.e. own logging within jobs code is enough) when using NLog (nlog.config):

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="info"
      internalLogFile="path_to_nlog_log_file">

  <!-- the targets to write to -->
  <targets async="true">
    <target name="database" type="Database">
      <commandText>
        <!-- insert into some table -->
      </commandText>
      <!-- parameters here -->
    </target>    

    <target xsi:type="Null" name="blackhole" />
  </targets>

  <!-- rules to map from logger name to target -->
  <rules>
    <!--Skip Microsoft/Quartz logs and so log only own logs-->
    <logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
    <logger name="Quartz*" minlevel="Trace" maxlevel="Info" writeTo="blackhole" final="true" />
    <logger name="*" minlevel="Debug" writeTo="database" />
  </rules>
</nlog>
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
0

If you want to only remove the abundant info & debug logs, I'd add

<logger name="Quartz.*" minlevel="Error" writeTo="default" final="true"/>

Based on this answer. This basically ensures Quartz assembly errors and fatal errors are written, but other logs are not.

Nae
  • 14,209
  • 7
  • 52
  • 79