BlazorExtensions / Logging

Microsoft Extension Logging implementation for Blazor
MIT License
215 stars 32 forks source link

Logging Objects #36

Closed brettwinters closed 5 years ago

brettwinters commented 5 years ago

Hello

I'm having some trouble getting objects to print in the console according to the readme "Additionaly, you're able to log an object in the browser console.".

I followed the instructions in the readme and then injected my @injects ILogger<MyClass> Logger in my .razor file.

The overload : logger.Information(forecasts) (found in your tests - which I can't get to compile) is not available (the closest is : Logger.LogInformation(string, args))

But anyway, I tried :

c# Logger.LogInformation("{testClass}", testClass); but only "[TestNamespace.TestClass] testClass" prints in Chrome (set to verbose)

I was thinking the output should be something like : "[TestNamespace.TestClass] { Name : test, "aliases": ["one", "two" ] }", for example...

Am I missing something?

galvesribeiro commented 5 years ago

Hello @brettwinters

image

I've just ran the sample here. The last line on the console on the picture is the one logging an object.

I've added this line https://github.com/BlazorExtensions/Logging/blob/master/test/Blazor.Extensions.Logging.Test/Pages/Index.razor#L21

Could you please pull the repo and check if that works for you?

brettwinters commented 5 years ago

Thanks for your help @galvesribeiro , unfortunately, after re-pulling I still can't get the solution to compile

MSB4044 "SourceLink.Create.CommandLine.CreateTask" task was not given a value for the required parameter "Commit". Blazor.Extensions.Logging

But anyway I figured out the problem : I was using @using Microsoft.Extensions.Logging but in fact I should have used `@using Blazor.Extensions.Logging' - which is why I could't see your overload.

You should point this out on your instructions for idiots like me haha