This repository was archived by the owner on Feb 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 6
6
using System ;
7
7
using System . IO ;
8
8
using System . Linq ;
9
+ using Microsoft . Extensions . Logging ;
10
+ using MMALSharp . Common . Utility ;
11
+ using NLog . Extensions . Logging ;
9
12
using Xunit ;
10
13
11
14
namespace MMALSharp . Tests
@@ -17,6 +20,16 @@ public class MMALFixture : IDisposable
17
20
18
21
public MMALFixture ( )
19
22
{
23
+ var loggerFactory = LoggerFactory . Create ( builder =>
24
+ {
25
+
26
+ builder
27
+ . ClearProviders ( )
28
+ . SetMinimumLevel ( LogLevel . Trace )
29
+ . AddNLog ( "NLog.config" ) ;
30
+ } ) ;
31
+
32
+ MMALLog . LoggerFactory = loggerFactory ;
20
33
}
21
34
22
35
public void CheckAndAssertFilepath ( string filepath )
Original file line number Diff line number Diff line change 1
1
<Project Sdk =" Microsoft.NET.Sdk" >
2
2
<PropertyGroup >
3
- <OutputType >Exe</OutputType >
3
+ <!-- < OutputType>Exe</OutputType> -- >
4
4
<AssemblyTitle >MMALSharp.Tests</AssemblyTitle >
5
- <TargetFramework >netcoreapp2.2 </TargetFramework >
5
+ <TargetFramework >net472 </TargetFramework >
6
6
<IsPackable >false</IsPackable >
7
7
<AssemblyName >MMALSharp.Tests</AssemblyName >
8
8
<PackageId >MMALSharp.Tests</PackageId >
15
15
<Folder Include =" Properties\" />
16
16
</ItemGroup >
17
17
<ItemGroup >
18
+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 3.1.0" />
18
19
<PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 16.4.0" />
20
+ <PackageReference Include =" NLog.Extensions.Logging" Version =" 1.6.1" />
19
21
<PackageReference Include =" StyleCop.Analyzers" Version =" 1.0.2" >
20
22
<PrivateAssets >All</PrivateAssets >
21
23
</PackageReference >
34
36
<Service Include =" {82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
35
37
</ItemGroup >
36
38
<ItemGroup >
39
+ <None Update =" NLog.config" >
40
+ <CopyToOutputDirectory >PreserveNewest</CopyToOutputDirectory >
41
+ </None >
37
42
<None Update =" xunit.runner.json" >
38
43
<CopyToOutputDirectory >PreserveNewest</CopyToOutputDirectory >
39
44
</None >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
3
+ <nlog xmlns =" http://www.nlog-project.org/schemas/NLog.xsd" xsi : schemaLocation =" NLog NLog.xsd"
4
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5
+ autoReload =" true"
6
+ internalLogFile =" ${basedir}/console-example-internal.log"
7
+ internalLogLevel =" Info" >
8
+
9
+ <!-- the targets to write to -->
10
+ <targets >
11
+ <!-- write logs to file -->
12
+ <target xsi : type =" File" name =" target1" fileName =" ${basedir}/mmal-log-${shortdate}.log"
13
+ layout =" ${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
14
+ <target xsi : type =" Console" name =" target2"
15
+ layout =" ${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-event-properties}" />
16
+ </targets >
17
+
18
+ <!-- rules to map from logger name to target -->
19
+ <rules >
20
+ <logger name =" *" minlevel =" Trace" writeTo =" target1" />
21
+ <logger name =" *" minlevel =" Info" writeTo =" target2" />
22
+ </rules >
23
+ </nlog >
You can’t perform that action at this time.
0 commit comments