Skip to content

Commit 6b932b4

Browse files
authored
Merge pull request #13 from nblumhardt/rtm-deps
Update to Serilog.Extensions.Logging 3.0
2 parents 204fe13 + 4632471 commit 6b932b4

File tree

4 files changed

+15
-41
lines changed

4 files changed

+15
-41
lines changed

README.md

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Serilog logging for _Microsoft.Extensions.Hosting_. This package routes framework log messages through Serilog, so you can get information about the framework's internal operations written to the same Serilog sinks as your application events.
44

5+
**ASP.NET Core** applications should consider [using _Serilog.AspNetCore_ instead](https://github.com/serilog/serilog-aspnetcore), which bundles this package and includes other ASP.NET Core-specific features.
6+
57
### Instructions
68

79
**First**, install the _Serilog.Extensions.Hosting_ [NuGet package](https://www.nuget.org/packages/Serilog.Extensions.Hosting) into your app. You will need a way to view the log messages - _Serilog.Sinks.Console_ writes these to the console; there are [many more sinks available](https://www.nuget.org/packages?q=Tags%3A%22serilog%22) on NuGet.
@@ -63,7 +65,7 @@ That's it! You will see log output like:
6365
[22:10:39 INF] The current time is: 12/05/2018 10:10:39 +00:00
6466
```
6567

66-
A more complete example, showing _appsettings.json_ configuration, can be found in [the sample project here](https://github.com/serilog/serilog-hostinh/tree/dev/samples/SimpleServiceSample).
68+
A more complete example, showing _appsettings.json_ configuration, can be found in [the sample project here](https://github.com/serilog/serilog-hosting/tree/dev/samples/SimpleServiceSample).
6769

6870
### Using the package
6971

@@ -78,39 +80,11 @@ You can alternatively configure Serilog using a delegate as shown below:
7880
```csharp
7981
// dotnet add package Serilog.Settings.Configuration
8082
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
81-
.ReadFrom.Configuration(hostingContext.Configuration)
82-
.Enrich.FromLogContext()
83-
.WriteTo.Console())
83+
.ReadFrom.Configuration(hostingContext.Configuration)
84+
.Enrich.FromLogContext()
85+
.WriteTo.Console())
8486
```
8587

8688
This has the advantage of making the `hostingContext`'s `Configuration` object available for configuration of the logger, but at the expense of recording `Exception`s raised earlier in program startup.
8789

8890
If this method is used, `Log.Logger` is assigned implicitly, and closed when the app is shut down.
89-
90-
### Writing to the Azure Diagnostics Log Stream
91-
92-
The Azure Diagnostic Log Stream ships events from any files in the `D:\home\LogFiles\` folder. To enable this for your app, first install the _Serilog.Sinks.File_ package:
93-
94-
```powershell
95-
Install-Package Serilog.Sinks.File
96-
```
97-
98-
Then add a file sink to your `LoggerConfiguration`, taking care to set the `shared` and `flushToDiskInterval` parameters:
99-
100-
```csharp
101-
public static int Main(string[] args)
102-
{
103-
Log.Logger = new LoggerConfiguration()
104-
.MinimumLevel.Debug()
105-
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
106-
.Enrich.FromLogContext()
107-
.WriteTo.Console()
108-
// Add this line:
109-
.WriteTo.File(
110-
@"D:\home\LogFiles\Application\myapp.txt",
111-
fileSizeLimitBytes: 1_000_000,
112-
rollOnFileSizeLimit: true,
113-
shared: true,
114-
flushToDiskInterval: TimeSpan.FromSeconds(1))
115-
.CreateLogger();
116-
```

samples/SimpleServiceSample/SimpleServiceSample.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.0-rc1-final" />
17-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0-rc1-final" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0-rc1-final" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0-rc1-final" />
20-
<PackageReference Include="Serilog.Sinks.Console" Version="3.0.1" />
21-
<PackageReference Include="Serilog.Settings.Configuration" Version="2.4.0" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
17+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
18+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
20+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
21+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
2222
</ItemGroup>
2323

2424
</Project>

src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Serilog support for .NET Core logging in hosted services</Description>
@@ -24,7 +24,7 @@
2424

2525
<ItemGroup>
2626
<PackageReference Include="Serilog" Version="2.8.0" />
27-
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.0-*" />
27+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
2828
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" />
2929
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.0" />
3030
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" />

test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
1818
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)