Hangfire.Console.Extensions icon indicating copy to clipboard operation
Hangfire.Console.Extensions copied to clipboard

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

Open xumix opened this issue 3 years ago • 7 comments

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

xumix avatar Jun 30 '22 08:06 xumix

Are you using it with serilog or without?

AnderssonPeter avatar Jun 30 '22 16:06 AnderssonPeter

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.

AnderssonPeter avatar Jun 30 '22 16:06 AnderssonPeter

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

xumix avatar Jun 30 '22 16:06 xumix

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 avatar Jun 30 '22 16:06 AnderssonPeter

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

AnderssonPeter avatar Jun 30 '22 16:06 AnderssonPeter

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?

xumix avatar Jun 30 '22 17:06 xumix

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

AnderssonPeter avatar Jun 30 '22 19:06 AnderssonPeter

Closed du to inactivity, please reopen if needed!

AnderssonPeter avatar Sep 28 '23 18:09 AnderssonPeter

@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

Abdruggi avatar Feb 23 '24 11:02 Abdruggi