-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from serilog/dev
7.0.0 Release
- Loading branch information
Showing
38 changed files
with
1,846 additions
and
1,679 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
root = true | ||
|
||
[*] | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
end_of_line = lf | ||
|
||
[*.{csproj,json,config,yml,props}] | ||
indent_size = 2 | ||
|
||
[*.sh] | ||
end_of_line = lf | ||
|
||
[*.{cmd, bat}] | ||
end_of_line = crlf | ||
|
||
# C# formatting settings - Namespace options | ||
csharp_style_namespace_declarations = file_scoped:suggestion | ||
|
||
csharp_style_prefer_switch_expression = true:suggestion |
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,12 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile> | ||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</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,3 @@ | ||
<Project> | ||
|
||
</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
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 was deleted.
Oops, something went wrong.
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,79 +1,68 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Serilog; | ||
using Serilog.Extensions.Logging; | ||
|
||
namespace Sample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
// Creating a `LoggerProviderCollection` lets Serilog optionally write | ||
// events through other dynamically-added MEL ILoggerProviders. | ||
var providers = new LoggerProviderCollection(); | ||
// Creating a `LoggerProviderCollection` lets Serilog optionally write | ||
// events through other dynamically-added MEL ILoggerProviders. | ||
var providers = new LoggerProviderCollection(); | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console() | ||
.WriteTo.Providers(providers) | ||
.CreateLogger(); | ||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console() | ||
.WriteTo.Providers(providers) | ||
.CreateLogger(); | ||
|
||
var services = new ServiceCollection(); | ||
var services = new ServiceCollection(); | ||
|
||
services.AddSingleton(providers); | ||
services.AddSingleton<ILoggerFactory>(sc => | ||
{ | ||
var providerCollection = sc.GetService<LoggerProviderCollection>(); | ||
var factory = new SerilogLoggerFactory(null, true, providerCollection); | ||
services.AddSingleton(providers); | ||
services.AddSingleton<ILoggerFactory>(sc => | ||
{ | ||
var providerCollection = sc.GetService<LoggerProviderCollection>(); | ||
var factory = new SerilogLoggerFactory(null, true, providerCollection); | ||
foreach (var provider in sc.GetServices<ILoggerProvider>()) | ||
factory.AddProvider(provider); | ||
foreach (var provider in sc.GetServices<ILoggerProvider>()) | ||
factory.AddProvider(provider); | ||
return factory; | ||
}); | ||
return factory; | ||
}); | ||
|
||
services.AddLogging(l => l.AddConsole()); | ||
services.AddLogging(l => l.AddConsole()); | ||
|
||
var serviceProvider = services.BuildServiceProvider(); | ||
var logger = serviceProvider.GetRequiredService<ILogger<Program>>(); | ||
var serviceProvider = services.BuildServiceProvider(); | ||
var logger = serviceProvider.GetRequiredService<ILogger<Program>>(); | ||
|
||
var startTime = DateTimeOffset.UtcNow; | ||
logger.LogInformation(1, "Started at {StartTime} and 0x{Hello:X} is hex of 42", startTime, 42); | ||
var startTime = DateTimeOffset.UtcNow; | ||
logger.LogInformation(1, "Started at {StartTime} and 0x{Hello:X} is hex of 42", startTime, 42); | ||
|
||
try | ||
{ | ||
throw new Exception("Boom!"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.LogCritical("Unexpected critical error starting application", ex); | ||
logger.Log(LogLevel.Critical, 0, "Unexpected critical error", ex, null); | ||
// This write should not log anything | ||
logger.Log<object>(LogLevel.Critical, 0, null, null, null); | ||
logger.LogError("Unexpected error", ex); | ||
logger.LogWarning("Unexpected warning", ex); | ||
} | ||
try | ||
{ | ||
throw new Exception("Boom!"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.LogCritical(ex, "Unexpected critical error starting application"); | ||
logger.Log(LogLevel.Critical, 0, "Unexpected critical error", ex, null!); | ||
// This write should not log anything | ||
logger.Log<object>(LogLevel.Critical, 0, null!, null, null!); | ||
logger.LogError(ex, "Unexpected error"); | ||
logger.LogWarning(ex, "Unexpected warning"); | ||
} | ||
|
||
using (logger.BeginScope("Main")) | ||
{ | ||
logger.LogInformation("Waiting for user input"); | ||
var key = Console.Read(); | ||
logger.LogInformation("User pressed {@KeyInfo}", new { Key = key, KeyChar = (char)key }); | ||
} | ||
using (logger.BeginScope("Main")) | ||
{ | ||
logger.LogInformation("Waiting for user input"); | ||
var key = Console.Read(); | ||
logger.LogInformation("User pressed {@KeyInfo}", new { Key = key, KeyChar = (char)key }); | ||
} | ||
|
||
var endTime = DateTimeOffset.UtcNow; | ||
logger.LogInformation(2, "Stopping at {StopTime}", endTime); | ||
var endTime = DateTimeOffset.UtcNow; | ||
logger.LogInformation(2, "Stopping at {StopTime}", endTime); | ||
|
||
logger.LogInformation("Stopping"); | ||
logger.LogInformation("Stopping"); | ||
|
||
logger.LogInformation(Environment.NewLine); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:l}{EndTime,15:l}{Duration,15:l}", "RESULT", "START TIME", "END TIME", "DURATION(ms)"); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:l}{EndTime,15:l}{Duration,15:l}", "------", "----- ----", "--- ----", "------------"); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:mm:s tt}{EndTime,15:mm:s tt}{Duration,15}", "SUCCESS", startTime, endTime, (endTime - startTime).TotalMilliseconds); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:l}{EndTime,15:l}{Duration,15:l}", "RESULT", "START TIME", "END TIME", "DURATION(ms)"); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:l}{EndTime,15:l}{Duration,15:l}", "------", "----- ----", "--- ----", "------------"); | ||
logger.LogInformation("{Result,-10:l}{StartTime,15:mm:s tt}{EndTime,15:mm:s tt}{Duration,15}", "SUCCESS", startTime, endTime, (endTime - startTime).TotalMilliseconds); | ||
|
||
serviceProvider.Dispose(); | ||
} | ||
} | ||
} | ||
serviceProvider.Dispose(); |
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,21 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<AssemblyName>Sample</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<PackageId>Sample</PackageId> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</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
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,12 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=destructure/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=destructured/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Destructurer/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Destructures/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=enricher/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=enrichers/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Loggable/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nonscalar/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=sobj/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stringification/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=stringified/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
Oops, something went wrong.