-
Notifications
You must be signed in to change notification settings - Fork 148
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 #240 from serilog/dev
Release 5.2.0
- Loading branch information
Showing
38 changed files
with
902 additions
and
215 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,3 @@ | ||
# Code of Conduct | ||
|
||
Please refer to the [Serilog Code of Conduct](https://github.com/serilog/serilog/blob/dev/CODE_OF_CONDUCT.md) which covers all repositories within the Serilog Organization. |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="MSSqlServerSettingsSection" type="Serilog.Configuration.MSSqlServerConfigurationSection, Serilog.Sinks.MSSqlServer" /> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
<MSSqlServerSettingsSection> | ||
<AddStandardColumns> | ||
<add Name="LogEvent" /> | ||
</AddStandardColumns> | ||
<RemoveStandardColumns> | ||
<remove Name="Properties" /> | ||
</RemoveStandardColumns> | ||
<TimeStamp ColumnName="TimeStampAlternative" ConvertToUtc="true" /> | ||
</MSSqlServerSettingsSection> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-3.1.2.0" newVersion="3.1.2.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{7DC530B1-68FD-4F07-A2F9-910C338562C1}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>AppConfigDemo</RootNamespace> | ||
<AssemblyName>AppConfigDemo</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.2\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Extensions.Primitives, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.3.1.2\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\Serilog.2.6.0\lib\net46\Serilog.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Numerics" /> | ||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj"> | ||
<Project>{803cd13a-d54b-4cec-a55f-e22ae3d93b3c}</Project> | ||
<Name>Serilog.Sinks.MSSqlServer</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</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,41 @@ | ||
using Serilog; | ||
using Serilog.Events; | ||
using Serilog.Sinks.MSSqlServer; | ||
using System; | ||
using System.Threading; | ||
|
||
namespace AppConfigDemo | ||
{ | ||
public class Program | ||
{ | ||
const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;"; | ||
const string _schemaName = "dbo"; | ||
const string _tableName = "LogEvents"; | ||
|
||
public static void Main() | ||
{ | ||
Log.Logger = new LoggerConfiguration().WriteTo | ||
.MSSqlServer( | ||
connectionString: _connectionString, | ||
tableName: _tableName, | ||
restrictedToMinimumLevel: LogEventLevel.Debug, | ||
batchPostingLimit: MSSqlServerSink.DefaultBatchPostingLimit, | ||
period: null, | ||
formatProvider: null, | ||
autoCreateSqlTable: true, | ||
columnOptions: null, | ||
schemaName: _schemaName, | ||
logEventFormatter: null) | ||
.CreateLogger(); | ||
|
||
Log.Debug("Getting started"); | ||
|
||
Log.Information("Hello {Name} from thread {ThreadId}", Environment.GetEnvironmentVariable("USERNAME"), | ||
Thread.CurrentThread.ManagedThreadId); | ||
|
||
Log.Warning("No coins remain at position {@Position}", new { Lat = 25, Long = 134 }); | ||
|
||
Log.CloseAndFlush(); | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("AppConfigDemo")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("AppConfigDemo")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("7dc530b1-68fd-4f07-a2f9-910c338562c1")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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"?> | ||
<packages> | ||
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.1.2" targetFramework="net461" /> | ||
<package id="Microsoft.Extensions.Primitives" version="3.1.2" targetFramework="net461" /> | ||
<package id="Serilog" version="2.6.0" targetFramework="net461" /> | ||
<package id="Serilog.Settings.AppSettings" version="2.2.2" targetFramework="net461" /> | ||
<package id="System.Buffers" version="4.4.0" targetFramework="net461" /> | ||
<package id="System.Memory" version="4.5.2" targetFramework="net461" /> | ||
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net461" /> | ||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net461" /> | ||
</packages> |
12 changes: 12 additions & 0 deletions
12
sample/CustomLogEventFormatterDemo/CustomLogEventFormatterDemo.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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
19 changes: 19 additions & 0 deletions
19
sample/CustomLogEventFormatterDemo/FlatLogEventFormatter.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,19 @@ | ||
using Serilog.Events; | ||
using Serilog.Formatting; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace CustomLogEventFormatterDemo | ||
{ | ||
public class FlatLogEventFormatter : ITextFormatter | ||
{ | ||
public void Format(LogEvent logEvent, TextWriter output) | ||
{ | ||
logEvent.Properties.ToList().ForEach(e => | ||
{ | ||
output.Write($"{e.Key}={e.Value} "); | ||
}); | ||
output.WriteLine(); | ||
} | ||
} | ||
} |
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,57 @@ | ||
using Serilog; | ||
using Serilog.Sinks.MSSqlServer; | ||
using System; | ||
using System.Threading; | ||
|
||
namespace CustomLogEventFormatterDemo | ||
{ | ||
public class Program | ||
{ | ||
const string _connectionString = "Server=localhost;Database=LogTest;Integrated Security=SSPI;"; | ||
const string _schemaName = "dbo"; | ||
const string _tableName = "LogEvents"; | ||
|
||
public static void Main() | ||
{ | ||
var options = new ColumnOptions(); | ||
options.Store.Add(StandardColumn.LogEvent); | ||
var customFormatter = new FlatLogEventFormatter(); | ||
Log.Logger = new LoggerConfiguration() | ||
.WriteTo.MSSqlServer(_connectionString, | ||
_tableName, | ||
appConfiguration: null, | ||
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose, | ||
batchPostingLimit: 50, | ||
period: null, | ||
formatProvider: null, | ||
autoCreateSqlTable: true, | ||
columnOptions: options, | ||
columnOptionsSection: null, | ||
schemaName: _schemaName, | ||
logEventFormatter: customFormatter) | ||
.CreateLogger(); | ||
|
||
try | ||
{ | ||
Log.Debug("Getting started"); | ||
|
||
Log.Information("Hello {Name} from thread {ThreadId}", Environment.GetEnvironmentVariable("USERNAME"), Thread.CurrentThread.ManagedThreadId); | ||
|
||
Log.Warning("No coins remain at position {@Position}", new { Lat = 25, Long = 134 }); | ||
|
||
Fail(); | ||
} | ||
catch (DivideByZeroException e) | ||
{ | ||
Log.Error(e, "Division by zero"); | ||
} | ||
|
||
Log.CloseAndFlush(); | ||
} | ||
|
||
static void Fail() | ||
{ | ||
throw new DivideByZeroException(); | ||
} | ||
} | ||
} |
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 @@ | ||
using Serilog.Events; | ||
using Serilog.Formatting; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace WorkerServiceDemo | ||
{ | ||
public class CustomLogEventFormatter : ITextFormatter | ||
{ | ||
public static CustomLogEventFormatter Formatter { get; } = new CustomLogEventFormatter(); | ||
|
||
public void Format(LogEvent logEvent, TextWriter output) | ||
{ | ||
logEvent.Properties.ToList() | ||
.ForEach(e => output.Write($"{e.Key}={e.Value} ")); | ||
} | ||
} | ||
} |
Oops, something went wrong.