renamed Class1 to NLogger.cs.
implemented ILogger interface for NLog logger. added Chainsaw NLogConfig.xml file. #9
This commit is contained in:
parent
fd015f1070
commit
f73fb9d345
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="NLogConfigFilePath" value="Configs/NLogConfig.xml"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NLogLogger
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?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">
|
||||
<targets>
|
||||
<target name="viewer" xsi:type="Chainsaw" address="udp://127.0.0.1:4000" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="viewer" />
|
||||
</rules>
|
||||
</nlog>
|
||||
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>1c5220d6-9166-4f47-b57d-beb4d09d2a3f</ProjectGuid>
|
||||
<ProjectGuid>{1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NLogLogger</RootNamespace>
|
||||
@ -30,25 +30,39 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.2\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
<Reference Include="System.Data" />
|
||||
|
||||
<Reference Include="System.Net.Http" />
|
||||
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="NLogger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
|
||||
<Project>{B7347B72-E208-423A-9D99-723B558EA3D7}</Project>
|
||||
<Name>Interfaces</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="NLogConfig.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</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.
|
||||
@ -57,5 +71,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
||||
120
DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogger.cs
Normal file
120
DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogger.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using ILogger = Interfaces.ILogger;
|
||||
|
||||
namespace NLogLogger
|
||||
{
|
||||
public class NLogger:ILogger
|
||||
{
|
||||
private NLog.Logger _logger;
|
||||
public NLogger()
|
||||
{
|
||||
var nlogConfigPath = ConfigurationManager.AppSettings["NLogConfigFilePath"];
|
||||
if (nlogConfigPath == null)
|
||||
{
|
||||
throw new ArgumentNullException("nlogConfigPath");
|
||||
}
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(nlogConfigPath);
|
||||
_logger = LogManager.GetLogger("");
|
||||
}
|
||||
|
||||
public bool IsDebugEnabled { get { return _logger.IsDebugEnabled; } }
|
||||
public bool IsErrorEnabled { get { return _logger.IsErrorEnabled; } }
|
||||
public bool IsFatalEnabled { get { return _logger.IsFatalEnabled; } }
|
||||
public bool IsInfoEnabled { get { return _logger.IsInfoEnabled; } }
|
||||
public bool IsTraceEnabled { get { return _logger.IsTraceEnabled; } }
|
||||
public bool IsWarnEnabled { get { return _logger.IsWarnEnabled; } }
|
||||
|
||||
public void Debug(Exception exception)
|
||||
{
|
||||
_logger.Debug(exception);
|
||||
}
|
||||
|
||||
public void Debug(string format, params object[] args)
|
||||
{
|
||||
_logger.Debug(format, args);
|
||||
}
|
||||
|
||||
public void Debug(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Debug(exception, format, args);
|
||||
}
|
||||
|
||||
public void Error(Exception exception)
|
||||
{
|
||||
_logger.Error(exception);
|
||||
}
|
||||
|
||||
public void Error(string format, params object[] args)
|
||||
{
|
||||
_logger.Error(format, args);
|
||||
}
|
||||
|
||||
public void Error(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Error(exception, format, args);
|
||||
}
|
||||
|
||||
public void Fatal(Exception exception)
|
||||
{
|
||||
_logger.Fatal(exception);
|
||||
}
|
||||
|
||||
public void Fatal(string format, params object[] args)
|
||||
{
|
||||
_logger.Fatal(format, args);
|
||||
}
|
||||
|
||||
public void Fatal(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Fatal(exception, format, args);
|
||||
}
|
||||
|
||||
public void Info(Exception exception)
|
||||
{
|
||||
_logger.Info(exception);
|
||||
}
|
||||
|
||||
public void Info(string format, params object[] args)
|
||||
{
|
||||
_logger.Info(format, args);
|
||||
}
|
||||
|
||||
public void Info(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Info(exception, format, args);
|
||||
}
|
||||
|
||||
public void Trace(Exception exception)
|
||||
{
|
||||
_logger.Trace(exception);
|
||||
}
|
||||
|
||||
public void Trace(string format, params object[] args)
|
||||
{
|
||||
_logger.Trace(format, args);
|
||||
}
|
||||
|
||||
public void Trace(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Trace(exception, format, args);
|
||||
}
|
||||
|
||||
public void Warn(Exception exception)
|
||||
{
|
||||
_logger.Warn(exception);
|
||||
}
|
||||
|
||||
public void Warn(string format, params object[] args)
|
||||
{
|
||||
_logger.Warn(format, args);
|
||||
}
|
||||
|
||||
public void Warn(Exception exception, string format, params object[] args)
|
||||
{
|
||||
_logger.Warn(exception, format, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.4.2" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user