From edf508a8dc48c5171afed7afc8d248713b7410f9 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Fri, 9 Mar 2018 17:13:11 +0100 Subject: [PATCH] Add console logging. --- ATxDiagnostics/ATxDiagnostics.cs | 18 ++++++++++++++++-- ATxDiagnostics/ATxDiagnostics.csproj | 8 ++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ATxDiagnostics/ATxDiagnostics.cs b/ATxDiagnostics/ATxDiagnostics.cs index d547c33..7f1c725 100644 --- a/ATxDiagnostics/ATxDiagnostics.cs +++ b/ATxDiagnostics/ATxDiagnostics.cs @@ -1,12 +1,26 @@ using System; using ATxCommon; +using NLog; +using NLog.Config; +using NLog.Targets; namespace ATxDiagnostics { class ATxDiagnostics { - static void Main(string[] args) - { + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); + + static void Main(string[] args) { + var logConfig = new LoggingConfiguration(); + var logTargetConsole = new ConsoleTarget { + Name = "console", + Header = "test-header", + }; + logConfig.AddTarget(logTargetConsole); + var logRuleConsole = new LoggingRule("*", LogLevel.Trace, logTargetConsole); + logConfig.LoggingRules.Add(logRuleConsole); + LogManager.Configuration = logConfig; + Console.WriteLine(SystemChecks.WmiSummary()); } } diff --git a/ATxDiagnostics/ATxDiagnostics.csproj b/ATxDiagnostics/ATxDiagnostics.csproj index 645124b..d234b10 100644 --- a/ATxDiagnostics/ATxDiagnostics.csproj +++ b/ATxDiagnostics/ATxDiagnostics.csproj @@ -33,6 +33,14 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <ItemGroup> + <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> + <HintPath>..\packages\NLog.4.3.11\lib\net45\NLog.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + </ItemGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> -- GitLab