Giter VIP home page Giter VIP logo

Comments (1)

ppumkin avatar ppumkin commented on June 8, 2024

Your logger provider can implement ISupportExternalScope
which you need to then implement SetScopeProvider in the provider.
And you can either make your own ScopeProvider then or extend Microsofts one to do what you want by newing up LoggerExternalScopeProvider in the LoggerExternalScopeProvider

Yea its a bit gobbly gook but its actually separated out really nicely.. just not documented anywhere. We spent quite some time working this out by looking at the source code in MS.

So any way there are a few things you can do now really.. In the implementation of Log in your Logger you can access more information in the ScopeProvider. For example we loop the scope to avoid wrapping BeginScope in usings.. We just use it as tracking steps so we loop over the scopes and dump them into our logs.

We also created like our own IFormatScopes interface which we can add on our objects and when we loop the scopes we do some type checking in a switch, if we have this interface then we call the GetScopes method on it and its in the format that we want. You could also have that implement the actual log data if you wanted.

From here its all really in your control.. Just make sure its really fast to work with these scopes .. if you find your self needing to use async.. well thats wrong you cant do that.. These need to be rapid because in production you WILL have this hitting thousands of times a second if not more.

from stackify-api-dotnet.

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.