+ Log.Debug( m=>m("result is {0}", random.NextDouble()) );
+ Log.Debug(delegate(m) { m("result is {0}", random.NextDouble()); });
+
+
+ // configure for capturing
+ CapturingLoggerFactoryAdapter adapter = new CapturingLoggerFactoryAdapter();
+ LogManager.Adapter = adapter;
+
+ // reset capture state
+ adapter.Clear();
+ // log something
+ ILog log = LogManager.GetCurrentClassLogger();
+ log.DebugFormat("Current Time:{0}", DateTime.Now);
+
+ // check logged data
+ Assert.AreEqual(1, adapter.LoggerEvents.Count);
+ Assert.AreEqual(LogLevel.Debug, adapter.LastEvent.Level);
+
+
+ <system.diagnostics>
+ <sharedListeners>
+ <add name="Diagnostics"
+ type="Common.Logging.Simple.CommonLoggingTraceListener, Common.Logging"
+ initializeData="DefaultTraceEventType=Information; LoggerNameFormat={listenerName}.{sourceName}">
+ <filter type="System.Diagnostics.EventTypeFilter" initializeData="Information"/>
+ </add>
+ </sharedListeners>
+ <trace>
+ <listeners>
+ <add name="Diagnostics" />
+ </listeners>
+ </trace>
+ </system.diagnostics>
+
+ + Primary purpose of this method is to allow us to parse and + load configuration sections using the same API regardless + of the .NET framework version. +
++ Primary purpose of this method is to allow us to parse and + load configuration sections using the same API regardless + of the .NET framework version. +
+
+ <configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+ </configSections>
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="showLogName" value="true" />
+ <arg key="showDataTime" value="true" />
+ <arg key="level" value="ALL" />
+ <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
+ </factoryAdapter>
+ </logging>
+ </common>
+ </configuration>
+
+
+
+ ILog log = LogManager.GetLogger(this.GetType());
+ ...
+ try
+ {
+ /* .... */
+ }
+ catch(Exception ex)
+ {
+ log.ErrorFormat("Hi {0}", ex, "dude");
+ }
+
+
+ The example below shows programmatic configuration of the underlying log system:
+
+
+ // create properties
+ NameValueCollection properties = new NameValueCollection();
+ properties["showDateTime"] = "true";
+
+ // set Adapter
+ Common.Logging.LogManager.Adapter = new
+ Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
+
+
+
+ ILog log = LogManager.GetLogger(this.GetType());
+
+ log.DebugFormat("Hi {0}", "dude");
+
+
+ <configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="DEBUG" />
+ </factoryAdapter>
+ </logging>
+ </common>
+ </configuration>
+
+
+ public class ConsoleOutLogger : AbstractSimpleLogger
+ {
+ public ConsoleOutLogger(string logName, LogLevel logLevel, bool showLevel, bool showDateTime,
+ bool showLogName, string dateTimeFormat)
+ : base(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
+ {
+ }
+
+ protected override void WriteInternal(LogLevel level, object message, Exception e)
+ {
+ // Use a StringBuilder for better performance
+ StringBuilder sb = new StringBuilder();
+ FormatOutput(sb, level, message, e);
+
+ // Print to the appropriate destination
+ Console.Out.WriteLine(sb.ToString());
+ }
+ }
+
+ public class ConsoleOutLoggerFactoryAdapter : AbstractSimpleLoggerFactoryAdapter
+ {
+ public ConsoleOutLoggerFactoryAdapter(NameValueCollection properties)
+ : base(properties)
+ { }
+
+ protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool
+ showDateTime, bool showLogName, string dateTimeFormat)
+ {
+ ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName,
+ dateTimeFormat);
+ return log;
+ }
+ }
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.NoOpLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+
+ Log.Debug( m=>m("result is {0}", random.NextDouble()) );
+ Log.Debug(delegate(m) { m("result is {0}", random.NextDouble()); });
+
+
+ // configure for capturing
+ CapturingLoggerFactoryAdapter adapter = new CapturingLoggerFactoryAdapter();
+ LogManager.Adapter = adapter;
+
+ // reset capture state
+ adapter.Clear();
+ // log something
+ ILog log = LogManager.GetCurrentClassLogger();
+ log.DebugFormat("Current Time:{0}", DateTime.Now);
+
+ // check logged data
+ Assert.AreEqual(1, adapter.LoggerEvents.Count);
+ Assert.AreEqual(LogLevel.Debug, adapter.LastEvent.Level);
+
+
+ <system.diagnostics>
+ <sharedListeners>
+ <add name="Diagnostics"
+ type="Common.Logging.Simple.CommonLoggingTraceListener, Common.Logging"
+ initializeData="DefaultTraceEventType=Information; LoggerNameFormat={listenerName}.{sourceName}">
+ <filter type="System.Diagnostics.EventTypeFilter" initializeData="Information"/>
+ </add>
+ </sharedListeners>
+ <trace>
+ <listeners>
+ <add name="Diagnostics" />
+ </listeners>
+ </trace>
+ </system.diagnostics>
+
+ + Primary purpose of this method is to allow us to parse and + load configuration sections using the same API regardless + of the .NET framework version. +
++ Primary purpose of this method is to allow us to parse and + load configuration sections using the same API regardless + of the .NET framework version. +
+
+ <configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+ </configSections>
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="showLogName" value="true" />
+ <arg key="showDataTime" value="true" />
+ <arg key="level" value="ALL" />
+ <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
+ </factoryAdapter>
+ </logging>
+ </common>
+ </configuration>
+
+
+
+ ILog log = LogManager.GetLogger(this.GetType());
+ ...
+ try
+ {
+ /* .... */
+ }
+ catch(Exception ex)
+ {
+ log.ErrorFormat("Hi {0}", ex, "dude");
+ }
+
+
+ The example below shows programmatic configuration of the underlying log system:
+
+
+ // create properties
+ NameValueCollection properties = new NameValueCollection();
+ properties["showDateTime"] = "true";
+
+ // set Adapter
+ Common.Logging.LogManager.Adapter = new
+ Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
+
+
+
+ ILog log = LogManager.GetLogger(this.GetType());
+
+ log.DebugFormat("Hi {0}", "dude");
+
+
+ <configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="DEBUG" />
+ </factoryAdapter>
+ </logging>
+ </common>
+ </configuration>
+
+
+ public class ConsoleOutLogger : AbstractSimpleLogger
+ {
+ public ConsoleOutLogger(string logName, LogLevel logLevel, bool showLevel, bool showDateTime,
+ bool showLogName, string dateTimeFormat)
+ : base(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
+ {
+ }
+
+ protected override void WriteInternal(LogLevel level, object message, Exception e)
+ {
+ // Use a StringBuilder for better performance
+ StringBuilder sb = new StringBuilder();
+ FormatOutput(sb, level, message, e);
+
+ // Print to the appropriate destination
+ Console.Out.WriteLine(sb.ToString());
+ }
+ }
+
+ public class ConsoleOutLoggerFactoryAdapter : AbstractSimpleLoggerFactoryAdapter
+ {
+ public ConsoleOutLoggerFactoryAdapter(NameValueCollection properties)
+ : base(properties)
+ { }
+
+ protected override ILog CreateLogger(string name, LogLevel level, bool showLevel, bool
+ showDateTime, bool showLogName, string dateTimeFormat)
+ {
+ ILog log = new ConsoleOutLogger(name, level, showLevel, showDateTime, showLogName,
+ dateTimeFormat);
+ return log;
+ }
+ }
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.NoOpLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+
+ <configuration>
+
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging"
+ type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
+ requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
+ <arg key="level" value="ALL" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ </configuration>
+
+ true
, a non-durable job can be stored. Once it is
+ scheduled, it will resume normal non-durable behavior (i.e. be deleted
+ once there are no remaining associated triggers).
+ true
.
- July August September
- Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
- 1 W 1 2 3 4 5 W 1 2 W
- W H 5 6 7 8 W W 8 9 10 11 12 W W H 6 7 8 9 W
- W 11 12 13 14 15 W W 15 16 17 18 19 W W 12 13 14 15 16 W
- W 18 19 20 21 22 W W 22 23 24 25 26 W W 19 20 21 22 23 W
- W 25 26 27 28 29 W W 29 30 31 W 26 27 28 29 30
- W
-
- Where W's represent weekend days, and H's represent holidays, all of which
- are excluded on a calendar associated with an
-
- If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY,
- then the instruction will be interpreted as
-
JobDataMap
key that can be used to retrieve the scheduled
+ fire time of the original Trigger
from a recovery trigger's data
+ map in the case of a job recovering after a failed scheduler instance.
+ true
, a non-durable job can be stored. Once it is
+ scheduled, it will resume normal non-durable behavior (i.e. be deleted
+ once there are no remaining associated triggers).
+ true
.
- July August September
- Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
- 1 W 1 2 3 4 5 W 1 2 W
- W H 5 6 7 8 W W 8 9 10 11 12 W W H 6 7 8 9 W
- W 11 12 13 14 15 W W 15 16 17 18 19 W W 12 13 14 15 16 W
- W 18 19 20 21 22 W W 22 23 24 25 26 W W 19 20 21 22 23 W
- W 25 26 27 28 29 W W 29 30 31 W 26 27 28 29 30
- W
-
- Where W's represent weekend days, and H's represent holidays, all of which
- are excluded on a calendar associated with an
-
- If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY,
- then the instruction will be interpreted as
-
JobDataMap
key that can be used to retrieve the scheduled
+ fire time of the original Trigger
from a recovery trigger's data
+ map in the case of a job recovering after a failed scheduler instance.
+ true
, a non-durable job can be stored. Once it is
+ scheduled, it will resume normal non-durable behavior (i.e. be deleted
+ once there are no remaining associated triggers).
+ true
.
- July August September
- Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
- 1 W 1 2 3 4 5 W 1 2 W
- W H 5 6 7 8 W W 8 9 10 11 12 W W H 6 7 8 9 W
- W 11 12 13 14 15 W W 15 16 17 18 19 W W 12 13 14 15 16 W
- W 18 19 20 21 22 W W 22 23 24 25 26 W W 19 20 21 22 23 W
- W 25 26 27 28 29 W W 29 30 31 W 26 27 28 29 30
- W
-
- Where W's represent weekend days, and H's represent holidays, all of which
- are excluded on a calendar associated with an
-
- If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY,
- then the instruction will be interpreted as
-
JobDataMap
key that can be used to retrieve the scheduled
+ fire time of the original Trigger
from a recovery trigger's data
+ map in the case of a job recovering after a failed scheduler instance.
+ true
, a non-durable job can be stored. Once it is
+ scheduled, it will resume normal non-durable behavior (i.e. be deleted
+ once there are no remaining associated triggers).
+ true
.
- July August September
- Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
- 1 W 1 2 3 4 5 W 1 2 W
- W H 5 6 7 8 W W 8 9 10 11 12 W W H 6 7 8 9 W
- W 11 12 13 14 15 W W 15 16 17 18 19 W W 12 13 14 15 16 W
- W 18 19 20 21 22 W W 22 23 24 25 26 W W 19 20 21 22 23 W
- W 25 26 27 28 29 W W 29 30 31 W 26 27 28 29 30
- W
-
- Where W's represent weekend days, and H's represent holidays, all of which
- are excluded on a calendar associated with an
-
- If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY,
- then the instruction will be interpreted as
-
JobDataMap
key that can be used to retrieve the scheduled
+ fire time of the original Trigger
from a recovery trigger's data
+ map in the case of a job recovering after a failed scheduler instance.
+