1. Bernie Rivera
  2. PowerBuilder
  3. Friday, 20 September 2019 15:14 PM UTC

I see that you use ILogger to capture errors in some of you PowerBuilder.Data objects.  I have a couple of questions.  I am not sure how to use this method other than the method you show in one of your examples.

var factory = new LoggerFactory();
var logger = factory.CreateLogger("Logger");

I was able to get this to work, but I had to add the Nuget Package for "Microsoft.Extensions.Logging.Console".

Question #1

How would I implement logging errors to the Console in an alternative way since it gives the following warning?

'ConsoleLoggerExtensions.AddConsole(ILoggerFactory)' is obsolete: 'This method is obsolete and will be removed in a future version. The recommended alternative is AddConsole(this ILoggingBuilder builder).'


Question #2

How would I capture errors in a non Console solution?


Forgive me for my ignorance.  I have attempted to figure this out on my own, but have been unsuccessful.  Code examples of usage for both questions would be appreciated.  


Thanks for any help anyone can give me.


Michael Kramer Accepted Answer Pending Moderation
  1. Friday, 20 September 2019 15:40 PM UTC
  2. PowerBuilder
  3. # 1

ILogger is very generic interface for any kind of log like log to console, log to Windows event log, log to MS Application Insights , or whatever else.

ASP.NET Core heavily uses dependency injection to create the actual object instances to deliver the interfaces you request. 

.NET Core is quickly maturing. For each version you see potentially breaking changes - or notifications that a breaking change may appear in an upcoming version.

You see that specific warning because probably .NET Core 2.2/3.0 will use a different mechanism to create loggers than you have chosen. There is SO MUCH happening in .NET Core and ASP.NET Core that it is hard to keep track.

My advice => Don't worry! When it works don't fix it. When it is fast enough don't tune it.


I have found a great deal of knowledge in Pluralsight courses - and YouTube videos when I'm selective on what presenters I "trust".

There's a separate Pluralsight course on logging alone, including ILogger, LoggerFactory, etc.

HTH /Michael

  1. Bernie Rivera
  2. Friday, 20 September 2019 15:53 PM UTC
Thanks I will take a look at the Pluralsight course.
  1. Helpful
  1. Michael Kramer
  2. Friday, 20 September 2019 16:04 PM UTC
Course name = Effective Logging in ASP.NET Core.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.