Git Product home page Git Product logo

Comments (7)

huorswords avatar huorswords commented on July 23, 2024

Hello @moberacker ,

No problem to add the Trace() extension method.

But with the Critical / Fatal one, I have concerns, because right now the Critical LogLevel already is registering a Fatal message. I will take a deep look and I'll be back to you.

Thank you by your help. Regards.

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 23, 2024

Hello again @moberacker ,

Do you have any justification to propose to change from Fatal to Critical?

For me are both the same, considering this SO answer: https://stackoverflow.com/a/5278006/982431

Let me know your thougts on this.

from microsoft.extensions.logging.log4net.aspnetcore.

moberacker avatar moberacker commented on July 23, 2024

Hello @huorswords ,

because I think it's more usefull to map Microsoft.Extensions.Logging.LogLevel Critical to the depending level of the underlying Logging Framework if it is available. Maybe you could add an appsettings property to support this mapping by configuration?

Regards,
Markus

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 23, 2024

Hello @moberacker ,

I am working for some time on this issue, and I have implemented a way to be able to use Critical instead Fatal following your suggestion and using your extension methods. Thank you very much.

To be able to setup the log level for critical messages within Critical level instead of the fatal one (by default), you should initialize AddLog4Net using a Log4NetProviderOptions class.

The OverrideCriticalLevelWith property of this class allows you to indicate "Critical" to let the logger know that should use Critical level instead of the Fatal level when a Critical message is sent to be written by the logger. Any other value, is not considered and use Fatal as default.

You can configure the Log4NetProviderOptions class by two ways:

  • Manually on your code.
  • When you initialize the log4net logging module, import the appsettings.json section, adding something like the following into your appsettings.json
"Log4NetCore": {
	"OverrideCriticalLevelWith": "Critical",
}

Is it a valid approach for you?

Thank you.

from microsoft.extensions.logging.log4net.aspnetcore.

moberacker avatar moberacker commented on July 23, 2024

Hello @huorswords ,

yes it's ok but don't forget to also include OverrrideTraceLevelWith : "Trace" to Log4NetCore.

Regrards,
Markus

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 23, 2024

Hello,

Not needed. The Trace level itself will be registered as is instead the actual behavior, that is via Debug level.

I will merge the changes as soon as possible and the new release will be available in the same day.

Thank you very much.

from microsoft.extensions.logging.log4net.aspnetcore.

huorswords avatar huorswords commented on July 23, 2024

Available on v.2.2.5

Please refer to documentation for more details.

from microsoft.extensions.logging.log4net.aspnetcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.