关闭Quartz .Net中的Debug Logging

Gan*_*esh 17 .net quartz.net

我正在使用Quartz.NET在我们的应用程序中安排一些自定义任务.一切正常,只是它在一秒钟内记录了大约20个调试条目.

我不知道如何关闭调试日志记录.任何帮助都会非常感激,因为我一直试图在网上查找而没有运气.

调试条目如下所示

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
Run Code Online (Sandbox Code Playgroud)

Mar*_*nze 22

如果您希望减少通过常用日志记录基础结构的所有日志记录,Rytmis的回答非常好.

但是如果你有更多的代码通过Common Logging进行日志记录,并且你只想减少从Quartz(而不是代码的其余部分)的日志记录,那么我建议的是:

在log4net config xml(app.config通常)你可能已经有这样的东西:

    <root>
        <level value="ALL" />
        <appender-ref ... />
        ...
    </root>
Run Code Online (Sandbox Code Playgroud)

保持原样.之后(或<log4net>配置部分内的任何地方)只需添加:

    <logger name="Quartz">
        <level value="ERROR" />
    </logger>
Run Code Online (Sandbox Code Playgroud)

<logger>节将配置名称为"Quartz"的所有记录器.因此,在此示例中,Quartz将以级别进行日志记录,ERROR而我的应用程序的其余部分将以级别记录ALL.

  • 实际上,问题不在于如何提高您的一般日志记录级别,因此,应将其标记为答案,因为这可以解决问题。 (2认同)

Pet*_*ter 11

如果任何人需要在NLog中执行此操作,只需在NLog.Config中添加以下内容作为顶级moste规则

<!-- Disable Quartz info logging -->
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />
Run Code Online (Sandbox Code Playgroud)

请注意,这仍然会让警告,错误,致命转到其他记录器,如果你不希望出现这种情况的变化maxlevel="Info"maxlevel="Fatal"


Ryt*_*mis 7

Quartz.net使用Common.Logging,所以你的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>
Run Code Online (Sandbox Code Playgroud)

请确保将youradapterhere更改为您正在使用的实际日志记录适配器,或者如果要完全禁用日志记录,请更改NoOpLoggerFactoryAdapter.


**编辑:**基于Ganesh的评论:

<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>
Run Code Online (Sandbox Code Playgroud)

**编辑2:**

为了那些不想阅读注释的人的好处,日志级别实际上是在log4net root配置中设置的:

<log4net>
    <root>
        <level value="DEBUG" /> <!-- This is the value that needed changing -->
        <appender-ref ref="Console" />
        <appender-ref ref="RollingFile" />
    </root>
</log4net>
Run Code Online (Sandbox Code Playgroud)


xwp*_*ram 6

在我关闭 Quartz.net 日志记录的情况下,我只需在配置 Scheduler 的 C# 代码中添加此属性。

LogProvider.IsDisabled = true;

总视图:

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);
    }
Run Code Online (Sandbox Code Playgroud)

并且不要忘记使用以下命令添加它:

using Quartz.Logging;
Run Code Online (Sandbox Code Playgroud)