exceptionless / Exceptionless.Net

Exceptionless clients for the .NET platform
https://exceptionless.com
Other
560 stars 142 forks source link

Does it support configuring appsettings. json? #317

Open Sc7-git opened 5 days ago

Sc7-git commented 5 days ago
  "Logging": {
    "LogLevel": {
      "Default": "Error"
    },
    "Exceptionless": {
      "LogLevel": {
        "Default": "Error"
      }
    },
    "ExceptionlessLogger": {
      "LogLevel": {
        "Default": "Error"
      }
    },
    "ExceptionlessLoggerProvider": {
      "LogLevel": {
        "Default": "Error"
      }
    }
  }

I found the alias Console in the Console LoggerProvider, but did not find any alias in the Exceptional LoggerProvider. Attempted Exceptionless, ExceptionlessLogger, and ExceptionlessLoggerProvider, but none of them worked. Information logs are still being recorded

Image

I want to exclude the info log and try using the following configuration, but it still doesn't work. logging.AddExceptionless(config => config.SetDefaultMinLogLevel(Exceptionless.Logging.LogLevel.Error));

niemyjski commented 4 days ago

SetDefaultMinLogLevel is used for initial setup until server-side log level settings are available.

To integrate with Microsoft's logging, use the Exceptionless.Extensions.Logging package https://github.com/exceptionless/Exceptionless.Net/tree/main/src/Platforms/Exceptionless.Extensions.Logging from NuGet. Rely on the existing logging configuration for Microsofts logging implementation, as we only serve as a logging provider. SetDefaultMinLogLevel and server log levels will apply to any log messages received to our logging provider (e.g., the ExceptionlessClient instance).

Sc7-git commented 4 days ago

@niemyjski I used Exceptionless.Extensions.Logging package, and configured logging.AddExceptionless(config => config.SetDefaultMinLogLevel(Exceptionless.Logging.LogLevel.Error));

But I still sent the info warn logs to the Exceptionless server, so I want to try configuring filtering out logs below the error level in the "appsettings.json", but the following configuration doesn't seem to have taken effect either

  "Logging": {
    "LogLevel": {
      "Default": "Error"
    },
    "Exceptionless": {
      "LogLevel": {
        "Default": "Error"
      }
    },
    "ExceptionlessLogger": {
      "LogLevel": {
        "Default": "Error"
      }
    },
    "ExceptionlessLoggerProvider": {
      "LogLevel": {
        "Default": "Error"
      }
    }
  }
niemyjski commented 4 days ago

What was your project log level settings set to? The SetDefaultMinLogLevel is replaced by the server side setting shortly after at startup.

AppSettings log level settings controls the Microsoft Logging and all of it's configured log providers (exceptionless is part of this), it's what gathers and forwards the logs if they are not filtered out by the config above to the exceptionless logging provider. Then exceptionless server side log levels come into play. So if you are filtering outto the error log level then exceptionless should never get anything lower than errors (unless you have fatal/critical log levels configured in exceptionless), then errors will be skipped by the exceptionless logging provider.

Sc7-git commented 3 days ago

What was your project log level settings set to? The SetDefaultMinLogLevel is replaced by the server side setting shortly after at startup.

AppSettings log level settings controls the Microsoft Logging and all of it's configured log providers (exceptionless is part of this), it's what gathers and forwards the logs if they are not filtered out by the config above to the exceptionless logging provider. Then exceptionless server side log levels come into play. So if you are filtering outto the error log level then exceptionless should never get anything lower than errors (unless you have fatal/critical log levels configured in exceptionless), then errors will be skipped by the exceptionless logging provider.

After configuring the console provider as default error, the console will only output logs above the error level, as follows:

  "Logging": {
    "LogLevel": {
      "Default": "Info"
    },
    "Console": {
      "LogLevel": {
        "Default": "Error"
      }
  }

So I think the Netcore framework can perform log level filtering through the provider.

I am planning to output low-level logs on the console and error level logs to Exceptionless. My ideal configuration would be as follows:

  "Logging": {
    "LogLevel": {
      "Default": "Info"
    },
    "Console": {
      "LogLevel": {
        "Default": "Info"
      },
    "Exceptionless": {
      "LogLevel": {
        "Default": "Error"
      }
    }
  }

But the configuration is not effective

niemyjski commented 3 days ago

If you could update our sample and debug this it would be a huge help. But I don't remember it working like this at least for our provider?