Skip to content

Commit 3f639e3

Browse files
authored
Merge pull request #105 from serilog/dev
2.0.1 Release
2 parents 8ed7d97 + 8f8d105 commit 3f639e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+72
-23709
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,5 @@ project.lock.json
199199

200200
# JetBrains Rider
201201
.idea
202+
203+
.vscode

README.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33

44
A Serilog provider for [Microsoft.Extensions.Logging](https://www.nuget.org/packages/Microsoft.Extensions.Logging), the logging subsystem used by ASP.NET Core.
55

6-
This package routes ASP.NET log messages through Serilog, so you can get information about ASP.NET's internal operations logged to the same Serilog sinks as your application events.
6+
### ASP.NET Core 2.0+ Instructions
77

8-
### Instructions
8+
ASP.NET Core 2.0 applications should prefer [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) and `UseSerilog()` instead.
99

10-
**First**, install the _Serilog.Extensions.Logging_ [NuGet package](https://www.nuget.org/packages/Serilog.Extensions.Logging) into your web or console app. You will need a way to view the log messages - _Serilog.Sinks.Literate_ writes these to the console.
10+
### ASP.NET Core 1.0, 1.1, and Default Provider Integration
11+
12+
The package implements `AddSerilog()` on `ILoggingBuilder` and `ILoggerFactory` to enable the Serilog provider under the default _Microsoft.Extensions.Logging_ implementation.
13+
14+
**First**, install the _Serilog.Extensions.Logging_ [NuGet package](https://www.nuget.org/packages/Serilog.Extensions.Logging) into your web or console app. You will need a way to view the log messages - _Serilog.Sinks.Console_ writes these to the console.
1115

1216
```powershell
1317
Install-Package Serilog.Extensions.Logging -DependencyVersion Highest
14-
Install-Package Serilog.Sinks.Literate
18+
Install-Package Serilog.Sinks.Console
1519
```
1620

1721
**Next**, in your application's `Startup` method, configure Serilog first:
@@ -25,40 +29,38 @@ public class Startup
2529
{
2630
Log.Logger = new LoggerConfiguration()
2731
.Enrich.FromLogContext()
28-
.WriteTo.LiterateConsole()
32+
.WriteTo.Console()
2933
.CreateLogger();
3034

3135
// Other startup code
3236
```
3337

3438
**Finally**, in your `Startup` class's `Configure()` method, remove the existing logger configuration entries and
35-
call `AddSerilog()` on the provided `loggerFactory`.
39+
call `AddSerilog()` on the provided `loggingBuilder`.
3640

3741
```csharp
38-
public void Configure(IApplicationBuilder app,
39-
IHostingEnvironment env,
40-
ILoggerFactory loggerfactory,
41-
IApplicationLifetime appLifetime)
42+
public void ConfigureServices(IServiceCollection services)
4243
{
43-
loggerfactory.AddSerilog();
44+
services.AddLogging(loggingBuilder =>
45+
loggingBuilder.AddSerilog(dispose: true));
4446

45-
// Ensure any buffered events are sent at shutdown
46-
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
47+
// Other services ...
48+
}
4749
```
4850

4951
That's it! With the level bumped up a little you should see log output like:
5052

5153
```
52-
2015-05-15 22:14:44.646 +10:00 [DBG] RouteCollection.RouteAsync
54+
[22:14:44.646 DBG] RouteCollection.RouteAsync
5355
Routes:
5456
Microsoft.AspNet.Mvc.Routing.AttributeRoute
5557
{controller=Home}/{action=Index}/{id?}
5658
Handled? True
57-
2015-05-15 22:14:44.647 +10:00 [DBG] RouterMiddleware.Invoke
59+
[22:14:44.647 DBG] RouterMiddleware.Invoke
5860
Handled? True
59-
2015-05-15 22:14:45.706 +10:00 [DBG] /lib/jquery/jquery.js not modified
60-
2015-05-15 22:14:45.706 +10:00 [DBG] /css/site.css not modified
61-
2015-05-15 22:14:45.741 +10:00 [DBG] Handled. Status code: 304 File: /css/site.css
61+
[22:14:45.706 DBG] /lib/jquery/jquery.js not modified
62+
[22:14:45.706 DBG] /css/site.css not modified
63+
[22:14:45.741 DBG] Handled. Status code: 304 File: /css/site.css
6264
```
6365

6466
### Credits

build.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
dotnet --info
3+
dotnet restore
4+
5+
for path in src/**/*.csproj; do
6+
dotnet build -f netstandard1.3 -c Release ${path}
7+
dotnet build -f netstandard2.0 -c Release ${path}
8+
9+
done
10+
11+
for path in test/*.Tests/*.csproj; do
12+
dotnet test -f netcoreapp2.0 -c Release ${path}
13+
done

samples/WebSample/.bowerrc

-3
This file was deleted.

samples/WebSample/Controllers/HomeController.cs

-58
This file was deleted.

samples/WebSample/Program.cs

-24
This file was deleted.

samples/WebSample/Project_Readme.html

-187
This file was deleted.

0 commit comments

Comments
 (0)