-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to .NET 8 RTM and Serilog 3.1.1
- Loading branch information
1 parent
0ea70d3
commit a234c68
Showing
11 changed files
with
144 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100-rc.2.23502.2" | ||
"version": "8.0.100" | ||
} | ||
} |
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
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,2 @@ | ||
FodyWeavers.xml | ||
FodyWeavers.xsd |
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,70 @@ | ||
using System.Reflection; | ||
using Microsoft.Extensions.Configuration; | ||
using Serilog; | ||
using Serilog.Debugging; | ||
using Serilog.Settings.Configuration; | ||
|
||
if (args.Length == 1 && args[0] == "is-single-file") | ||
{ | ||
if (typeof(Program).Assembly.GetManifestResourceNames().Any(e => e.StartsWith("costura."))) | ||
{ | ||
Console.WriteLine(true); | ||
return 0; | ||
} | ||
// IL3000: 'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app | ||
#pragma warning disable IL3000 | ||
Console.WriteLine(string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location)); | ||
#pragma warning restore | ||
return 0; | ||
} | ||
|
||
SelfLog.Enable(Console.Error); | ||
|
||
Thread.CurrentThread.Name = "Main thread"; | ||
const string outputTemplate = "({ThreadName}) [{Level}] {Message}{NewLine}"; | ||
|
||
var configurationValues = new Dictionary<string, string?>(); | ||
var minimumLevelOnly = args.Contains("--minimum-level-only"); | ||
if (minimumLevelOnly) | ||
{ | ||
configurationValues["Serilog:MinimumLevel"] = "Verbose"; | ||
} | ||
else | ||
{ | ||
configurationValues["Serilog:Enrich:0"] = "WithThreadName"; | ||
configurationValues["Serilog:WriteTo:0:Name"] = "Console"; | ||
configurationValues["Serilog:WriteTo:0:Args:outputTemplate"] = outputTemplate; | ||
} | ||
|
||
if (args.Contains("--using-thread")) configurationValues["Serilog:Using:Thread"] = "Serilog.Enrichers.Thread"; | ||
if (args.Contains("--using-console")) configurationValues["Serilog:Using:Console"] = "Serilog.Sinks.Console"; | ||
|
||
var assemblies = new List<Assembly>(); | ||
if (args.Contains("--assembly-thread")) assemblies.Add(typeof(ThreadLoggerConfigurationExtensions).Assembly); | ||
if (args.Contains("--assembly-console")) assemblies.Add(typeof(ConsoleLoggerConfigurationExtensions).Assembly); | ||
|
||
try | ||
{ | ||
var configuration = new ConfigurationBuilder().AddInMemoryCollection(configurationValues).Build(); | ||
var options = assemblies.Count > 0 ? new ConfigurationReaderOptions(assemblies.ToArray()) : null; | ||
var loggerConfiguration = new LoggerConfiguration().ReadFrom.Configuration(configuration, options); | ||
if (minimumLevelOnly) | ||
{ | ||
loggerConfiguration | ||
.Enrich.WithThreadName() | ||
.WriteTo.Console(outputTemplate: outputTemplate); | ||
} | ||
var logger = loggerConfiguration.CreateLogger(); | ||
logger.Information("Expected success"); | ||
return 0; | ||
} | ||
catch (InvalidOperationException exception) when (exception.Message.StartsWith("No Serilog:Using configuration section is defined and no Serilog assemblies were found.")) | ||
{ | ||
Console.WriteLine("Expected exception"); | ||
return 0; | ||
} | ||
catch (Exception exception) | ||
{ | ||
Console.Error.WriteLine(exception); | ||
return 1; | ||
} |
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,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net48</TargetFramework> | ||
<DebugType>embedded</DebugType> | ||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> | ||
<GenerateSupportedRuntime>false</GenerateSupportedRuntime> | ||
<PublishReferencesDocumentationFiles>false</PublishReferencesDocumentationFiles> | ||
<AllowedReferenceRelatedFileExtensions>none</AllowedReferenceRelatedFileExtensions> | ||
<UseCurrentRuntimeIdentifier>true</UseCurrentRuntimeIdentifier> | ||
<SelfContained>true</SelfContained> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="$(Configuration) == 'Debug'"> | ||
<ProjectReference Include="..\..\src\Serilog.Settings.Configuration\Serilog.Settings.Configuration.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$(Configuration) == 'Release'"> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="[0.0.0-IntegrationTest.0]" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<config> | ||
<add key="globalPackagesFolder" value="packages" /> | ||
</config> | ||
<packageSources> | ||
<clear /> | ||
<add key="local" value="." /> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
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