Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for logging to a file using Common.Logging which is par…

…t of Quartz. NLog was used as the file writing library and a rolling appender was placed in the config.
  • Loading branch information...
commit 31428c27b75480a937318ef3c1037e4219485906 1 parent 441a543
@jetheredge jetheredge authored
View
BIN  lib/Common.Logging.NLog.dll
Binary file not shown
View
BIN  lib/Common.Logging.dll
Binary file not shown
View
BIN  lib/NLog.dll
Binary file not shown
View
6 src/DaemonMaster/DaemonMaster.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
using Quartz;
@@ -69,7 +70,10 @@ public void Execute()
public void Shutdown()
{
- scheduler.Shutdown(true);
+ if (scheduler != null)
+ {
+ scheduler.Shutdown(true);
+ }
}
public bool IsShutdown()
View
28 src/DaemonMasterConsole/App.config
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+
+ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
+ <arg key="configType" value="INLINE" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <targets>
+ <target name="file1" xsi:type="File" fileName="logging.txt" archiveNumbering="Sequence"
+ archiveFileName="log_archive{###}.txt" archiveEvery="Day" autoFlush="True" maxArchiveFiles="10" />
+ </targets>
+ <rules>
+ <logger name="*" minlevel="Debug" writeTo="file1" />
+ </rules>
+ </nlog>
+</configuration>
View
16 src/DaemonMasterConsole/DaemonMasterConsole.csproj
@@ -31,6 +31,19 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Common.Logging.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="Common.Logging.NLog, Version=1.2.0.2, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Common.Logging.NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog, Version=1.0.0.505, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\NLog.dll</HintPath>
+ </Reference>
<Reference Include="Quartz, Version=1.0.1.3, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Quartz.dll</HintPath>
@@ -59,6 +72,9 @@
<Name>DaemonMaster</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
View
6 src/DaemonMasterConsole/TestJob.cs
@@ -1,10 +1,11 @@
using System;
+using System.Diagnostics;
using DaemonMaster;
using Quartz;
namespace DaemonMasterConsole
{
- /*public class TestJobDaemon: IIntervalDaemon
+ public class TestJobDaemon: IIntervalDaemon
{
public int interval
{
@@ -32,6 +33,7 @@ public class TestJob: IJob
public void Execute(JobExecutionContext context)
{
Console.WriteLine(context.JobDetail.FullName);
+ Debug.WriteLine("test");
}
- }*/
+ }
}
View
28 src/DaemonMasterService/App.config
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="common">
+ <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
+ </sectionGroup>
+
+ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
+ </configSections>
+
+ <common>
+ <logging>
+ <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
+ <arg key="configType" value="INLINE" />
+ </factoryAdapter>
+ </logging>
+ </common>
+
+ <nlog throwExceptions="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <targets>
+ <target name="file1" xsi:type="File" fileName="logging.txt" archiveNumbering="Sequence"
+ archiveFileName="log_archive{###}.txt" archiveEvery="Day" autoFlush="True" maxArchiveFiles="10" />
+ </targets>
+ <rules>
+ <logger name="*" minlevel="Debug" writeTo="file1" />
+ </rules>
+ </nlog>
+</configuration>
View
4 src/DaemonMasterService/DaemonMasterService.cs
@@ -17,16 +17,18 @@ namespace DaemonMasterService
{
public partial class DaemonMasterService : ServiceBase
{
- private DaemonMaster.DaemonMaster daemonMaster;
+ public DaemonMaster.DaemonMaster daemonMaster;
private void LoadDaemons()
{
daemonMaster = new DaemonMaster.DaemonMaster();
+ daemonMaster.Execute();
}
public DaemonMasterService()
{
InitializeComponent();
+ Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
}
protected override void OnStart(string[] args)
View
16 src/DaemonMasterService/DaemonMasterService.csproj
@@ -31,6 +31,19 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Common.Logging.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="Common.Logging.NLog, Version=1.2.0.2, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\Common.Logging.NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog, Version=1.0.0.505, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\NLog.dll</HintPath>
+ </Reference>
<Reference Include="Quartz, Version=1.0.1.3, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Quartz.dll</HintPath>
@@ -91,6 +104,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Please sign in to comment.
Something went wrong with that request. Please try again.