-
Notifications
You must be signed in to change notification settings - Fork 151
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
NLogLoggingConfiguration - Added support for default-wrapper, default-target-parameter & autoReload #283
Conversation
…ult-target-parameters
Codecov Report
@@ Coverage Diff @@
## master #283 +/- ##
==========================================
+ Coverage 70.45% 70.79% +0.33%
==========================================
Files 12 12
Lines 958 976 +18
Branches 170 178 +8
==========================================
+ Hits 675 691 +16
Misses 221 221
- Partials 62 64 +2
Continue to review full report at Codecov.
|
@304NotModified One more bullet in the chamber. Do we have other frequently used config-features? |
Have to check. One in mind, Do we support async=true on targets level? |
I was thinking the default-wrapper etc should be outside the wrappers (so next to it, instead of inside). Not sure of that's problematic (could image that!). If so, then is not a problem |
When you say "wrappers" then you mean "targets"-section ? For xml-config then Xml-config has support for multiple "targets"-sections with different "default-wrapper" and "default-target-parameters". Right now I'm focusing on a single "targets"-section since 99 out 100 are doing this. |
I was hoping one could just do this:
|
Yes and yes I know : 👼 |
I'm trying to make the JSON and XML config match as much as possible, unless there is a more natural JSON-formating (Ex. making use of JSON-dictionary-keys) I feel that Maybe one day JSON-config will be used with a targets-sections-array (very exotic and not sure if it is support by the current logic) "targets": [
{
"console": {
"type": "Console"
}
},
{
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Block"
},
"debugLog": {
"type": "File",
"fileName": "c:/temp/console-debug.log"
}
}
] |
Why is that? As xml and json have different conventions and limitations. I really prefer natural json over xml-with-json-sause. Of course, if this is too difficult in the code (for now), that's fine. |
PS. In the json there is now a possible name clash, and not in the xml version. |
I feel that I have been very diligent in trying to make the Json-format as pretty as possible. And the reason for making it close to xml-naming and xml-layout is because of documentation reuse. Allows the user to quickly map back and forth (And use the existing wiki). If you feel that the my choices in the Json-format are completely wack then we should probably rollback everything. Then you can start over.
Would be very obfuscating if someone started to name their actual targets "default-wrapper" or "default-target-parameters". Even in xml-version. |
Yes you are, sorry for the used words. Its not meant unkind. |
How much work would it be to get the new elements (default-wrapper,default-target-parameters) on level up? e.g. {
"NLog": {
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Block"
},
"default-target-parameters": {
"console": {
"error": "true",
},
"file": {
"encoding": "utf-8",
},
},
"targets": {
"console": {
"type": "Console"
},
"debugLog": {
"type": "File",
"fileName": "c:/temp/console-debug.log"
},
"errorLog": {
"type": "File",
"fileName": "c:/temp/console-error.log"
}
},
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "debugLog,Console"
},
{
"logger": "*",
"minLevel": "Error",
"writeTo": "errorLog"
}
]
}
} That would make this change even better IMO |
They are not new elements. They exists already in NLog-config-engine. Just feeding them properly so NLog can understand the Json-version.
Everything is possible with code. It is just gonna be very ugly. Have to inject the "special" children ( |
@304NotModified After having looked the code. Then I think I will let you have the honors of trying to bend the LoggingConfigurationParser to your will. |
Codecov Report
@@ Coverage Diff @@
## master #283 +/- ##
=========================================
+ Coverage 69.23% 73.7% +4.46%
=========================================
Files 11 12 +1
Lines 933 1080 +147
Branches 165 189 +24
=========================================
+ Hits 646 796 +150
+ Misses 226 220 -6
- Partials 61 64 +3
Continue to review full report at Codecov.
|
-> snakefoot#7 |
note: I think there is something wrong with the casing, #283 (comment) shows "targets", but It's implemented as "Targets"? |
Default wrapper and Default-target-parameters on top level
Sure hope everything is case-insensitive, else it would become nightmare. |
Lots of CodeFactor issues now after merge :) |
I will fix that (soon) |
do we need to check/test that? |
Should be handled automatically by LoggingConfigurationParser. Unless there is some case-sensitive logic in NLogLoggingConfiguration. |
changing NLogLoggingConfigurationTests, e.g. |
According to: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2
So calls to |
Nope it should not fail. |
I see the issue I think |
but maybe doubting if this is a good change |
I can change the casing without tests breaking. But running on my clean PR without your changes (And without case-insensitive-key-comparer on dictionary) |
But since you have identified a possible issue with breaking case-insensitivity, then it could be a good idea to have a test of this. |
yes, added some (in the current tests 👼 ) and this goes wrong: (not committed)
(lower case rules) this works
(lower case nlog) |
Any idea why? Just checked the NLog dev branch, but don't see the issue 123. |
Think you are now testing the test. Make sure to have all entries to have the same casing. Ex:
|
ow otherwise those are separate sections? (rules and Rules)? |
Could you change your "casing"-test so all entries are using the same casing ? |
But it won't break anything? |
Not sure I understand. Anyway will create a new PR when this is merged, since support for KeepVariablesOnReload is still missing |
done |
merged :) |
and default-target-parameters:
Example JSON-config: