Skip to content

2.0.0 Release #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1e4727a
Dev version bump [Skip CI]
nblumhardt Feb 14, 2017
2b6f2bb
Remove some redundant string formatting
nblumhardt Feb 15, 2017
e7d116f
Merge pull request #70 from nblumhardt/removeformatting
nblumhardt Feb 15, 2017
04baf4e
upgrade to dotnet CLI 1.0.3
adamchester Apr 22, 2017
5a79c7e
DisableImplicitFrameworkReferences
adamchester Apr 22, 2017
90393cd
Merge pull request #75 from serilog/dotnet-cli-1.0.3
nblumhardt Apr 22, 2017
2f25335
Include symbols nuget package
adamchester Apr 22, 2017
11583f2
Merge pull request #76 from serilog/dotnet-cli-1.0.3
nblumhardt Apr 22, 2017
07286fc
Ignore JetBrains Rider meta files.
gertjvr Jul 14, 2017
3fa0fcd
Added new extension method to configure serilog from services.
gertjvr Jul 14, 2017
b484f37
Update csproj to target netstandard 2.0
gertjvr Jul 14, 2017
62bfb8a
update to dotnet cli 2.0.0-preview2-006497
gertjvr Jul 14, 2017
1b940d7
Single char errors :(
gertjvr Jul 14, 2017
129caf9
Missing package references.
gertjvr Jul 14, 2017
16999cc
Not sure why Microsoft.Extensions.DependencyInjection isn't picked up.
gertjvr Jul 14, 2017
3f86602
Think I figured out what is wrong.
gertjvr Jul 15, 2017
882b821
Removed unneeded extension and updated the version prefix as requested.
gertjvr Jul 17, 2017
7a92b2f
Merge pull request #83 from gertjvr/dev
nblumhardt Jul 17, 2017
f4442ec
Moved logging extensions to target ILoggingBuilder and updated the s…
gertjvr Jul 17, 2017
5376280
Updated exception message.
gertjvr Jul 18, 2017
ea1193f
changed appveyor image to visual studio 2017 preview.
gertjvr Jul 18, 2017
53a914f
Changed extension name to SerilogLoggingBuilderExtensions
gertjvr Jul 18, 2017
86aeba9
Merge pull request #85 from gertjvr/dev
nblumhardt Jul 18, 2017
d5ff474
Include ILoggerFactory extensions on Core 2.0
nblumhardt Jul 31, 2017
dcc5e6d
Merge pull request #88 from nblumhardt/include-loggerfactory
nblumhardt Jul 31, 2017
5be654b
update to rtm 2.0 dependencies
Aug 15, 2017
a9b319f
Merge pull request #90 from skomis-mm/netstandard2
nblumhardt Aug 15, 2017
5516198
make `ILoggingBuilder.AddSerilog` fluent friendly
Aug 16, 2017
98dfb14
Merge pull request #92 from skomis-mm/loggerbuild
nblumhardt Aug 16, 2017
0c4bfbd
fix build script running on .net core 2.0 cli
Aug 17, 2017
7bda6f2
Merge pull request #93 from skomis-mm/ci
merbla Aug 17, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -196,3 +196,6 @@ FakesAssemblies/
*.opt
*.orig
project.lock.json

# JetBrains Rider
.idea
7 changes: 6 additions & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ foreach ($src in ls src/*) {

echo "build: Packaging project in $src"

& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
if($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts
}

if($LASTEXITCODE -ne 0) { exit 1 }

Pop-Location
Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2015
image: Visual Studio 2017 Preview
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-003121'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
#- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/release/2.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
#- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
#- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 2.0.0-preview2-006497'
#- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
build_script:
- ps: ./Build.ps1
test: off
Expand All @@ -27,4 +27,4 @@ deploy:
tag: v$(appveyor_build_version)
on:
branch: master

3 changes: 1 addition & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
"version": "2.0.0-preview2-006497"
}
}
17 changes: 11 additions & 6 deletions samples/Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;

namespace Sample
{
public static class Program
public class Program
{
public static void Main(string[] args)
{
Expand All @@ -13,18 +14,22 @@ public static void Main(string[] args)
.WriteTo.LiterateConsole()
.CreateLogger();

var logger = new LoggerFactory()
.AddSerilog()
.CreateLogger(typeof(Program).FullName);
var services = new ServiceCollection()
.AddLogging(builder =>
{
builder.AddSerilog();
});

logger.LogInformation("Starting");
var serviceProvider = services.BuildServiceProvider();
// getting the logger using the class's name is conventional
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);

try
{
throw new Exception("Boom");
throw new Exception("Boom!");
}
catch (Exception ex)
{
Expand Down
20 changes: 20 additions & 0 deletions samples/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Sample</PackageId>
</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="Serilog.Sinks.Literate" Version="2.0.0" />
</ItemGroup>

</Project>
15 changes: 0 additions & 15 deletions samples/Sample/Sample.xproj

This file was deleted.

27 changes: 0 additions & 27 deletions samples/Sample/project.json

This file was deleted.

9 changes: 6 additions & 3 deletions samples/WebSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ public Startup(IHostingEnvironment env)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(builder =>
{
// Specifying dispose: true closes and flushes the Serilog `Log` class when the app shuts down.
builder.AddSerilog(dispose: true);
});

// Add framework services.
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Specifying dispose: true closes and flushes the Serilog `Log` class when the app shuts down.
loggerFactory.AddSerilog(dispose: true);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down
41 changes: 41 additions & 0 deletions samples/WebSample/WebSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>WebSample</AssemblyName>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.3.1" />
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Literate" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="3.2.0" />
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
</Target>
<ItemGroup>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
</ItemGroup>
</Project>
23 changes: 0 additions & 23 deletions samples/WebSample/WebSample.xproj

This file was deleted.

70 changes: 0 additions & 70 deletions samples/WebSample/project.json

This file was deleted.

14 changes: 7 additions & 7 deletions serilog-extensions-logging.sln
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1893BD1-333D-4DFE-A0F0-DDBB2FE526E0}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Extensions.Logging", "src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.xproj", "{903CD13A-D54B-4CEC-A55F-E22AE3D93B3B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extensions.Logging", "src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj", "{903CD13A-D54B-4CEC-A55F-E22AE3D93B3B}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Extensions.Logging.Tests", "test\Serilog.Extensions.Logging.Tests\Serilog.Extensions.Logging.Tests.xproj", "{37EADF84-5E41-4224-A194-1E3299DCD0B8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extensions.Logging.Tests", "test\Serilog.Extensions.Logging.Tests\Serilog.Extensions.Logging.Tests.csproj", "{37EADF84-5E41-4224-A194-1E3299DCD0B8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E30F638E-BBBE-4AD1-93CE-48CC69CFEFE1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F2407211-6043-439C-8E06-3641634332E7}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample", "samples\Sample\Sample.xproj", "{65357FBC-9BC4-466D-B621-1C3A19BC2A78}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "samples\Sample\Sample.csproj", "{65357FBC-9BC4-466D-B621-1C3A19BC2A78}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{9C21B9DF-AEDD-4AA6-BEA4-912DEF3E5B8E}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
Build.ps1 = Build.ps1
global.json = global.json
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WebSample", "samples\WebSample\WebSample.xproj", "{486DF7EB-128D-4C79-8B97-9CEFEADDB948}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSample", "samples\WebSample\WebSample.csproj", "{486DF7EB-128D-4C79-8B97-9CEFEADDB948}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
14 changes: 11 additions & 3 deletions src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except

if (messageTemplate == null)
{
var propertyName = state != null ? "State" :
(formatter != null ? "Message" : null);
string propertyName = null;
if (state != null)
{
propertyName = "State";
messageTemplate = "{State:l}";
}
else if (formatter != null)
{
propertyName = "Message";
messageTemplate = "{Message:l}";
}

if (propertyName != null)
{
messageTemplate = $"{{{propertyName}:l}}";
LogEventProperty property;
if (logger.BindProperty(propertyName, AsLoggableValue(state, formatter), false, out property))
properties.Add(property);
Expand Down
Loading