Skip to content

LoggingConfigurationReader - Extracted from XmlLoggingConfiguration#2624

Closed
snakefoot wants to merge 1 commit intoNLog:devfrom
snakefoot:LoggingConfigurationReader
Closed

LoggingConfigurationReader - Extracted from XmlLoggingConfiguration#2624
snakefoot wants to merge 1 commit intoNLog:devfrom
snakefoot:LoggingConfigurationReader

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

@snakefoot snakefoot commented Mar 25, 2018

See also #1588

This is merely a proof of concept. I want to remove the quirks from LoggingConfigurationReader, so all the special reader logic for XML and JSON is moved into the specialized LoggingConfiguration-classes.

But if the Json-example presented is completely useless, then no need to proceed further down this road.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2018

Codecov Report

Merging #2624 into master will decrease coverage by <1%.
The diff coverage is 76%.

@@           Coverage Diff           @@
##           master   #2624    +/-   ##
=======================================
- Coverage      81%     81%   -<1%     
=======================================
  Files         326     327     +1     
  Lines       24034   24294   +260     
  Branches     3037    3088    +51     
=======================================
+ Hits        19443   19561   +118     
- Misses       3751    3889   +138     
- Partials      840     844     +4

@snakefoot snakefoot force-pushed the LoggingConfigurationReader branch from 6e2ac14 to 8c6d926 Compare March 25, 2018 18:35
@304NotModified 304NotModified added this to the 4.6 milestone Mar 25, 2018
@snakefoot snakefoot force-pushed the LoggingConfigurationReader branch from 8c6d926 to 9c4f81a Compare March 25, 2018 21:25
@snakefoot snakefoot force-pushed the LoggingConfigurationReader branch from 9c4f81a to 8a540e7 Compare March 25, 2018 22:18
Copy link
Copy Markdown
Member

@304NotModified 304NotModified left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please tell me what's new code, (no moves), makes it easier to review, thanks!

{
for (int i = LoggingRules.Count - 1; i >= 0; i--)
{
if (removedRules.Contains(LoggingRules[i]))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't better to use the rulename here? Or do you think we will have duplicate names?

/// <summary>
/// Interface for accessing configuration details
/// </summary>
public interface ILoggingConfigurationSection
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move classes/interfaces to separate files, thx!

@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Apr 2, 2018

Could you please tell me what's new code, (no moves), makes it easier to review, thanks!

Well before you start the review, then you should read the initial comment. Which I will repeat again. Is the Json-config shown in #1588 (comment) acceptable? (Along with all the restrictions)

@304NotModified
Copy link
Copy Markdown
Member

Well before you start the review, then you should read the initial comment. Which I will repeat again. Is the Json-config shown in #1588 (comment) acceptable? (Along with all the restrictions)

yes, I saw it. Have to think about the restrictions. .e.g if a variable is using another variable, that could be an issue (now it's dependent of the order)

Anyway, splitting the config reader from the XML config reader it a good step anyway.

@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Apr 2, 2018

.e.g if a variable is using another variable, that could be an issue (now it's dependent of the order)

Well the variables in the variables-section are parsed in their correct order. It is only the individual sections that are parsed in alphabetic order. (Ex variables-section are parsed last because it starts with "v", so like extensions-section it has to be pre-loaded).

@304NotModified
Copy link
Copy Markdown
Member

I think the targets config in the proposed JSON looks awesome! Would it be possible to change the "internalLog" and "extensions" section as in the opening post? And how should we configure rules without names?

@snakefoot
Copy link
Copy Markdown
Contributor Author

how should we configure rules without names?

The same way you configure targets without names. You don't :)

@304NotModified
Copy link
Copy Markdown
Member

Well the variables in the variables-section are parsed in their correct order.

So this goes well?

 "variables": {
            "rootDir": "c:/somewhere"
            "basedirArchives": "${rootDir}/archives",
            "basedirFiles": "${rootDir}/files",
        },

I a bit confused why that one isn't parsed alphabeticly. It it because "extentions" etc is the the intermediate child of the root? IMO Json are just properties and arrays.

The same way you configure targets without names. You don't :)

That will be hard for users to come up with unique names while they don't use it.

@snakefoot
Copy link
Copy Markdown
Contributor Author

Would it be possible to change the "internalLog" section as in the opening post?

I guess it is possible to fiddle with the LoggingConfigurationReader, so can support reading internalLog-parameters from a section different from the nlog-section.

Would it be possible to change the "extensions" section as in the opening post?

Nope. This Json is ignored by the microsoft json parser:

"NLog.Extended": {},

@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Apr 2, 2018

That will be hard for users to come up with unique names while they don't use it.

Same can be said for wrapped targets :). Also the names doesn't have to be unique. Just like the target-names (But maybe the Json-protocol will limit you).

@304NotModified
Copy link
Copy Markdown
Member

Same can be said for wrapped targets :)

true, but wrapped targets are less common/basic and now we have already unnamed rules.

@304NotModified
Copy link
Copy Markdown
Member

There is also no support for autoReload or including external json-files.

There is reloadOnChange (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration)

@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Apr 2, 2018

There is reloadOnChange

Sounds like you are ready to take over the PR, and fiddle with how to hook into the reloadOnChange-event and perform a controlled reload if something happened to the NLog-section.

@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Apr 2, 2018

true, but wrapped targets are less common/basic and now we have already unnamed rules.

I guess the logging-rules could be implemented like the extensions-section-array:

        "rules": [
            {
                "logger": "*",
                "minLevel": "Trace",
                "writeTo": "SplitGroup"
            },
            {
                "logger": "*",
                "minLevel": "Trace",
                "writeTo": "postFilteringWrapper"
            },
        ],

I just liked that the rules and targets where using the same syntax.

@304NotModified
Copy link
Copy Markdown
Member

304NotModified commented Apr 2, 2018

Sounds like you are ready to take over the PR, and fiddle with how to hook into the reloadOnChange-event and perform a controlled reload if something happened to the NLog-section.

I will try, but I don't expect if have time for that before the weekend.

I guess the logging-rules could be implemented like the extensions-section-array:

👍 nice!

@304NotModified
Copy link
Copy Markdown
Member

looks like I have an action to do here :)

@304NotModified
Copy link
Copy Markdown
Member

304NotModified commented Aug 4, 2018

I think this could be merged for 4.6, independent of the discussion of JSON config files, do you agree?

There is a pure refactoring, isn't ? I like to accept it.

@304NotModified 304NotModified changed the base branch from master to dev August 14, 2018 20:26
@snakefoot
Copy link
Copy Markdown
Contributor Author

snakefoot commented Aug 15, 2018

There is a pure refactoring, isn't ? I like to accept it.

No it is a bad attempt to reuse the XML-logic for reading JSON-files.

The reordering logic (because JSON-keys are ordered) need happen in the JSON-parser (and not in the reader).

The variable _xmlConfigMode need to be removed.

@304NotModified
Copy link
Copy Markdown
Member

No it is a bad attempt to reuse the XML-logic for reading JSON-files.

OK, I think I close it then (for now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants