Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add layout support for FinalMinLevel - #5174

#5174
Merged
snakefoot merged 19 commits into
NLog:devNLog/NLog:devfrom
Aaronmsv:feature/5172Aaronmsv/NLog:feature/5172Copy head branch name to clipboard
Mar 28, 2023
Merged

Add layout support for FinalMinLevel #5174
snakefoot merged 19 commits into
NLog:devNLog/NLog:devfrom
Aaronmsv:feature/5172Aaronmsv/NLog:feature/5172Copy head branch name to clipboard

Conversation

@Aaronmsv

@Aaronmsv Aaronmsv commented Mar 20, 2023

Copy link
Copy Markdown
Contributor

I tried to keep refactorings to a minimum and stay consistent with the rest of the code. Let me know if more changes are required. Resolves #5172

This commit adds support for configuring FinalLevelMin
through (environmental) variables.

Resolves #NLog#5172.
@welcome

welcome Bot commented Mar 20, 2023

Copy link
Copy Markdown

Thanks for opening this pull request!
We will try to review this soon! Please note that pull requests with unit tests are earlier accepted 👼

Comment thread src/NLog/Config/LoggingConfigurationParser.cs Outdated
@snakefoot

snakefoot commented Mar 20, 2023

Copy link
Copy Markdown
Contributor

Thank you for the unit-tests, that is a great step. Think the unit-test should also show that updating the NLog-Config-Variable and calling logFactory.ReconfigureExistingLoggers() will have effect on the active finalMinLevel. Which probably requires some help from ILoggingRuleLevelFilter (Just like for levels + minlevel + maxlevel)

@snakefoot snakefoot added this to the 5.1.3 milestone Mar 20, 2023
@Aaronmsv

Copy link
Copy Markdown
Contributor Author

Okay, so just to be clear: I add a new property to ILoggingRuleLevelFilter, update its implementations to handle this, and pass finalMinLevel to EnableLoggingForLevels, EnableLoggingForLevelLayout and EnableLoggingForLevelsLayout?

In my first try, I implemented a new ILoggingRuleLevelFilter and set it during parsing of finalMinLevel, but it just got cleared after EnableLevelsForRule was called. I think it misunderstood it then.

@snakefoot

snakefoot commented Mar 21, 2023 via email

Copy link
Copy Markdown
Contributor

@Aaronmsv

Aaronmsv commented Mar 22, 2023

Copy link
Copy Markdown
Contributor Author

What do you think of something like this?

Also, the unit test FinalMinLevelTest seems to be failing. But given this rule:

<logger name='RequestLogger' minLevel='Debug' finalMinLevel='Error' writeTo='requestTarget' />

Shouldn't the following log be ignored, since it is below Error from finalMinLevel?

requestLogger.Debug("Debug Noise");

I will add more tests if you agree with this approach.

@snakefoot

snakefoot commented Mar 22, 2023

Copy link
Copy Markdown
Contributor

Like the direction where LoggingRule FinalMinLevel-property now is implemented using _logLevelFilter.

Think you should merge FinalMinLogLevelLayoutFilter into DynamicLogLevelFilter and DynamicRangeLevelFilter, so you can use any combination of these:

  • Level / Levels comes from dynamic NLog Layout
  • FinalMinLevel comes from dynamic NLog Layout
  • MaxLevel comes from dynamic NLog Layout (range)
  • MinLevel comes from dynamic NLog Layout (range)

Shouldn't the following log be ignored, since it is below Error from finalMinLevel?

Lets say you have an application that depends on a special sub-module, and you want to have a dedicated log-target for that sub-module, but at the same time you would like all errors to flow to the catch-all log-target (but not info/warn):

<logger name='RequestLogger' minLevel='Debug' writeTo='requestTarget' finalMinLevel='Error' />
<logger name='*' minLevel='Info' writeTo='catchAllTarget' />

@snakefoot snakefoot changed the title Add layout support for FinalLevelMin Add layout support for FinalMinLevel Mar 25, 2023
@snakefoot snakefoot mentioned this pull request Mar 26, 2023
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

91.7% 91.7% Coverage
0.0% 0.0% Duplication

@snakefoot

snakefoot commented Mar 28, 2023

Copy link
Copy Markdown
Contributor

Sorry about the many small commits to your pull-request-branch. But it now looks like the pull-request is making FinalMinLevel work with NLog Layout.

Will squash the commits, and starting working on getting NLog v5.1.3 released.

Thanks for the unit-tests and pushing for getting this included.

@snakefoot snakefoot added the enhancement Improvement on existing feature label Mar 28, 2023
@snakefoot
snakefoot merged commit 00c3946 into NLog:dev Mar 28, 2023
@welcome

welcome Bot commented Mar 28, 2023

Copy link
Copy Markdown

Hooray your first pull request is merged! Thanks for the contribution! Looking for more? 👼 Please check the up-for-grabs issues - thanks!
thanks!

@Aaronmsv

Copy link
Copy Markdown
Contributor Author

Sorry for the late reply, last days were busy. Thanks @snakefoot!

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

Labels

enhancement Improvement on existing feature size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finalMinLevel not compatible with environment variables

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.