-
Notifications
You must be signed in to change notification settings - Fork 131
Fixes #97, #83, #98 #100
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
Fixes #97, #83, #98 #100
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bbf9b45
Merge pull request #1 from serilog/dev
MV10 7e14841
minor formatting cleanup; rollback of direct parm value during method…
MV10 90b87ba
changed null-ref checks to Any() tests on GetSection results
MV10 82375c0
confing binding and config section hinting
MV10 80b2ec9
populate value for an IConfiguration parameter on target method
MV10 1239fda
recognize IConfigurationSection parameter types
MV10 a81d1c6
docs for IConfigurationSection
MV10 60cf699
renamed const to NestedConfigHintChar
MV10 da883fa
fixed unit tests with config subsections
MV10 400b1de
moved ConfigurationSectionArgumentValue functionality into ObjectArgu…
MV10 f9754e4
unit test for IConfig, IConfigSection, and config object-binding
MV10 0b3b661
unit tests for string/int array arguments
MV10 0116625
Try removing pinned <Version> properties, etc, to match general Seril…
nblumhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -91,3 +91,39 @@ For example, to set the minimum log level using the _Windows_ command prompt: | |
set Serilog:MinimumLevel=Debug | ||
dotnet run | ||
``` | ||
|
||
### Nested configuration sections | ||
|
||
Some Serilog packages require a reference to a logger configuration object. The sample program in this project illustrates this with the following entry configuring the _Serilog.Sinks.Async_ package to wrap the _Serilog.Sinks.File_ package. The `configure` parameter references the File sink configuration: | ||
|
||
```json | ||
"WriteTo:Async": { | ||
"Name": "Async", | ||
"Args": { | ||
"configure": [ | ||
{ | ||
"Name": "File", | ||
"Args": { | ||
"path": "%TEMP%\\Logs\\serilog-configuration-sample.txt", | ||
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
``` | ||
|
||
### IConfiguration parameter | ||
|
||
If a Serilog package requires additional external configuration information (for example, access to a `ConnectionStrings` section, which would be outside of the `Serilog` section), the sink should include an `IConfiguration` parameter in the configuration extension method. This package will automatically populate that parameter. It should not be declared in the argument list in the configuration source. | ||
|
||
### Complex parameter value binding | ||
|
||
When the configuration specifies a discrete value for a parameter (such as a string literal), the package will attempt to convert that value to the target method's declared CLR type of the parameter. Additional explicit handling is provided for parsing strings to `Uri` and `TimeSpan` objects and `enum` elements. | ||
|
||
If the parameter value is not a discrete value, the package will use the configuration binding system provided by _Microsoft.Extensions.Options.ConfigurationExtensions_ to attempt to populate the parameter. Almost anything that can be bound by `IConfiguration.Get<T>` should work with this package. An example of this is the optional `List<Column>` parameter used to configure the .NET Standard version of the _Serilog.Sinks.MSSqlServer_ package. | ||
|
||
### IConfigurationSection parameters | ||
|
||
Certain Serilog packages may require configuration information that can't be easily represented by discrete values or direct binding-friendly representations. An example might be lists of values to remove from a collection of default values. In this case the method can accept an entire `IConfigurationSection` as a call parameter and this package will recognize that and populate the parameter. In this way, Serilog packages can support arbitrarily complex configuration scenarios. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in the long run that one is going to be very useful to sink authors. |
||
|
This file contains hidden or 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 contains hidden or 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 contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the additional docs 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to remove nested config "hint" hack -- but I left the blurb there about nested config support, figured it can't hurt to document it.