0

I recently used Liblog solution in my project to get logging abstraction. Everything is working fine but i have one small question.

My project is .Net Standard 2.0, hence i defined a compiler symbol "LIBLOG_PORTABLE"

After adding this, i am not able to call LogProvider.GetCurrentClassLogger(); as it is not available after above declaration. Hence now i am accessing my logger using following way.

LogProvider.SetCurrentLogProvider(new Logging.LogProviders.SerilogLogProvider());
Logger = LogProvider.GetLogger("SerilogLog");   

However, i am just confused how it supports logging abstraction for .Net Standard 2.0 if i am explicitly providing all these. Is it a correct way of doing it or i am missing something?

K D
  • 5,889
  • 1
  • 23
  • 35

1 Answers1

0

There is a sample in the Wiki.

public class MyClass
{
    private static readonly ILog Logger = LogProvider.For<MyClass>(); 

    public MyClass()
    {
        using(LogProvider.OpenNestedContext("message"))
        using(LogProvider.OpenMappedContext("key", "value"))
        {
            Logger.Info(....);
        }
    }
}

For more detailed reason why it is done so, please refer to the Wiki.

Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154