Skip to content

Commit 24e0a23

Browse files
committed
Update the README to use the new ReadFrom.Configuration() method
1 parent 366acd8 commit 24e0a23

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ Root section name can be changed:
6565
```
6666

6767
```csharp
68+
var context = new ConfigurationContext { SectionName = "CustomSection" };
6869
var logger = new LoggerConfiguration()
69-
.ReadFrom.Configuration(configuration, sectionName: "CustomSection")
70+
.ReadFrom.Configuration(configuration, context)
7071
.CreateLogger();
7172
```
7273

@@ -106,8 +107,9 @@ In case of [non-standard](#azure-functions-v2-v3) dependency management you can
106107
```csharp
107108
var functionDependencyContext = DependencyContext.Load(typeof(Startup).Assembly);
108109

110+
var context = new ConfigurationContext(functionDependencyContext) { SectionName = "AzureFunctionsJobHost:Serilog" };
109111
var logger = new LoggerConfiguration()
110-
.ReadFrom.Configuration(hostConfig, sectionName: "AzureFunctionsJobHost:Serilog", dependencyContext: functionDependencyContext)
112+
.ReadFrom.Configuration(hostConfig, context)
111113
.CreateLogger();
112114
```
113115

@@ -119,8 +121,9 @@ var configurationAssemblies = new[]
119121
typeof(ConsoleLoggerConfigurationExtensions).Assembly,
120122
typeof(FileLoggerConfigurationExtensions).Assembly,
121123
};
124+
var context = new ConfigurationContext(configurationAssemblies);
122125
var logger = new LoggerConfiguration()
123-
.ReadFrom.Configuration(configuration, configurationAssemblies)
126+
.ReadFrom.Configuration(configuration, context)
124127
.CreateLogger();
125128
```
126129

@@ -376,9 +379,9 @@ public class Startup : FunctionsStartup
376379
{
377380
var functionDependencyContext = DependencyContext.Load(typeof(Startup).Assembly);
378381

379-
var hostConfig = sp.GetRequiredService<IConfiguration>();
382+
var context = new ConfigurationContext(functionDependencyContext) { SectionName = "AzureFunctionsJobHost:Serilog" };
380383
var logger = new LoggerConfiguration()
381-
.ReadFrom.Configuration(hostConfig, sectionName: "AzureFunctionsJobHost:Serilog", dependencyContext: functionDependencyContext)
384+
.ReadFrom.Configuration(hostConfig, context)
382385
.CreateLogger();
383386

384387
return new SerilogLoggerProvider(logger, dispose: true);

0 commit comments

Comments
 (0)