Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an issue where restrictedToMinimumLevel from appsettings.json w…
…as ignored. (#168)
- Loading branch information
1 parent
f90ae5d
commit 105617b
Showing
9 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
samples/Serilog/SerilogTestCodeFromConfigRestrictedToMinimumLevel/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Serilog; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace SerilogTestCodeFromConfigRestrictedToMinimumLevel | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
// logger configuration reads from appsettings.json | ||
var configuration = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json") | ||
.Build(); | ||
|
||
var logger = new LoggerConfiguration() | ||
.ReadFrom.Configuration(configuration) | ||
.CreateLogger(); | ||
|
||
logger.Information("This should not log since restrictedToMinimumLevel is Error in appsettings.json!"); | ||
logger.Error("Hello!"); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...omConfigRestrictedToMinimumLevel/SerilogTestCodeFromConfigRestrictedToMinimumLevel.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AWS.Logger.SeriLog" Version="3.1.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> | ||
<PackageReference Include="Serilog" Version="2.10.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
samples/Serilog/SerilogTestCodeFromConfigRestrictedToMinimumLevel/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"Serilog": { | ||
"Using": [ | ||
"AWS.Logger.SeriLog" | ||
], | ||
"LogGroup": "Serilog.ConfigExample", | ||
"Region": "us-east-1", | ||
"MinimumLevel": "Information", | ||
"WriteTo": [ | ||
{ | ||
"Name": "AWSSeriLog", | ||
"Args": { | ||
"restrictedToMinimumLevel": "Error" | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/AWS.Logger.SeriLog.Tests/AWSSeriLogGroupRestrictedToMinimumLevel.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"Serilog": { | ||
"Using": [ "AWS.Logger.SeriLog" ], | ||
"MinimumLevel": "Debug", | ||
"LogGroup": "AWSSeriLogGroupRestrictedtoMinimumLevel", | ||
"Region": "us-west-2", | ||
"LogStreamNameSuffix": "Custom", | ||
"LogStreamNamePrefix": "CustomPrefix", | ||
"WriteTo": [ | ||
{ | ||
"Name": "AWSSeriLog", | ||
"Args": { | ||
"restrictedToMinimumLevel": "Error" | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters