AnderssonPeter / Hangfire.Console.Extensions

Makes it easier to use Hangfire.Console with .net core dependency injection
MIT License
79 stars 17 forks source link

[Q] How do you filter what goes to console and what level? #9

Closed xumix closed 1 year ago

xumix commented 2 years ago

There is no configuration for Hangfire.Console in the sample project appsettings.json

For Example, I want System.* be logged to console with Warning level but all my App.* logger be logged with Debug level

AnderssonPeter commented 2 years ago

Are you using it with serilog or without?

AnderssonPeter commented 2 years ago

In both cases its more about configuring the logging framework instead, the built in logging framework allows you to configure levels based on logger name, and serilog has a filter plugin you can use that archives the same thing.

xumix commented 2 years ago

In both cases its more about configuring the logging framework instead, the built in logging framework allows you to configure levels based on logger name, and serilog has a filter plugin you can use that archives the same thing.

I'm using the built-in logging with NLog on top, I've tried configuring it like this:

"Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Trace",
      "System": "Information",
      "OpenTracing": "Warning",
      "Jaeger": "Warning",
      "Microsoft": "Warning",
      "Microsoft.EntityFrameworkCore.Database.Command": "Information",
      "Hangfire": "Debug"
    },
    "Hangfire": {
      "Default": "Debug",
      "System": "Information",
      "OpenTracing": "Warning",
      "Jaeger": "Warning",
      "Microsoft": "Warning"
    }

But still got Trace messages in console

AnderssonPeter commented 2 years ago

Well if i was guessing it would have been what you just wrote, i sadly dont know exactly what is wrong. if i where you i would enable debug symbols for system.logging and and step into a logging call.

AnderssonPeter commented 2 years ago

Also have you tried to add that to my sample if it works there i think it's a problem with nlog?

xumix commented 2 years ago

Well if i was guessing it would have been what you just wrote, i sadly dont know exactly what is wrong. if i where you i would enable debug symbols for system.logging and and step into a logging call.

https://github.com/AnderssonPeter/Hangfire.Console.Extensions/blob/master/Hangfire.Console.Extensions/HangfireLogger.cs#L20= maybe this is the problem?

AnderssonPeter commented 2 years ago

That might be the case, could you provide a pr?

AnderssonPeter commented 1 year ago

Closed du to inactivity, please reopen if needed!

Abdruggi commented 8 months ago

@xumix The ProviderAliasAttribute is missing on the HangfireLoggerProvider. Therefore, it is not possible to configure log levels to filter logs. I created a pr to fix that.

https://github.com/AnderssonPeter/Hangfire.Console.Extensions/pull/15