Skip to content

Commit 0145775

Browse files
Merge pull request #99 from jamesbperry/master
Add a .NET console application sample
2 parents a47bb41 + cdcc961 commit 0145775

13 files changed

+3498
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "net-library-using-ms-logging", "src\net-library-using-ms-logging\net-library-using-ms-logging.csproj", "{CA2DBD9B-922F-4A9E-937E-5BDF309234C7}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "net-app-using-nlog", "src\net-app-using-nlog\net-app-using-nlog.csproj", "{6131A351-6275-4E64-8893-5E6E4E0860BE}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{CA2DBD9B-922F-4A9E-937E-5BDF309234C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{CA2DBD9B-922F-4A9E-937E-5BDF309234C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{CA2DBD9B-922F-4A9E-937E-5BDF309234C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{CA2DBD9B-922F-4A9E-937E-5BDF309234C7}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{6131A351-6275-4E64-8893-5E6E4E0860BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{6131A351-6275-4E64-8893-5E6E4E0860BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{6131A351-6275-4E64-8893-5E6E4E0860BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{6131A351-6275-4E64-8893-5E6E4E0860BE}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
5+
</configSections>
6+
<startup>
7+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
8+
</startup>
9+
<runtime>
10+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
11+
<dependentAssembly>
12+
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
13+
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
14+
</dependentAssembly>
15+
<dependentAssembly>
16+
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
17+
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
18+
</dependentAssembly>
19+
</assemblyBinding>
20+
</runtime>
21+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd Nlog.xsd" autoReload="true">
22+
<targets>
23+
<target name="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false" layout="${longdate}|${logger}|${pad:padding=5:inner=${level:uppercase=true}}|${message} ${exception:format=ToString,StackTrace}${newline}">
24+
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
25+
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
26+
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
27+
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
28+
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
29+
</target>
30+
</targets>
31+
<rules>
32+
<logger name="*" minlevel="Trace" writeTo="coloredConsole" />
33+
</rules>
34+
</nlog>
35+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Microsoft.Extensions.Logging;
2+
using net_library_using_ms_logging;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace net_app_using_nlog
10+
{
11+
class ExampleService : IExampleService
12+
{
13+
private readonly ExampleWorker _exampleWorker;
14+
private readonly ILogger _logger;
15+
16+
public ExampleService(ExampleWorker exampleWorker, ILogger<ExampleService> logger = null) //keeping exampleWorker concrete here for example simplicity...
17+
{
18+
_exampleWorker = exampleWorker;
19+
_logger = logger;
20+
}
21+
22+
public async Task DoSomethingAsync()
23+
{
24+
_logger?.LogInformation("Doing something!");
25+
26+
await _exampleWorker.DoWorkAsync();
27+
28+
_logger?.LogInformation("Did something!");
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace net_app_using_nlog
8+
{
9+
interface IExampleService
10+
{
11+
Task DoSomethingAsync();
12+
}
13+
}

0 commit comments

Comments
 (0)