BlazorExtensions / Logging

Microsoft Extension Logging implementation for Blazor
MIT License
216 stars 31 forks source link

[Inject] showing an error in Blazor library project #15

Closed MarkStega closed 6 years ago

MarkStega commented 6 years ago

I am trying to use the logging extensions outside of a cshtml file. In my class implementation RestProcessService I have placed

        [Inject]
        protected ILogger<RestProcessService> logger;

right after the class declaration. I get "Attibute 'inject' is not valid on this declaration type. It is only valid on 'property, indexer' declarations." when hovering over the red squiggles under "[Inject]".

galvesribeiro commented 6 years ago

Yes, that is not an issue o the Logging component.

As the message states, [Inject] only work on non-public properties, not on fields.

Please check Blazor docs for further details about it: https://blazor.net/docs/dependency-injection.html

Let me know if I can help you further.

MarkStega commented 6 years ago

@galvesribeiro

The sample inject is straight from the readme.md at the root of the logging repository so you probably should update that...

galvesribeiro commented 6 years ago

Sorry, I just fixed the Readme.md.