Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support configuring appsettings. json? #317

Open
Sc7-git opened this issue Nov 20, 2024 · 7 comments
Open

Does it support configuring appsettings. json? #317

Sc7-git opened this issue Nov 20, 2024 · 7 comments

Comments

@Sc7-git
Copy link

Sc7-git commented Nov 20, 2024

  "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
Copy link
Member

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
Copy link
Author

Sc7-git commented Nov 21, 2024

@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
Copy link
Member

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
Copy link
Author

Sc7-git commented Nov 22, 2024

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
Copy link
Member

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?

@Sc7-git
Copy link
Author

Sc7-git commented Dec 12, 2024

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?

I don't want to submit API service startup information and Swagger access logs to exceptionless. But it submitted by default. How can I troubleshoot this.
Image

Image

I guess this is possible, but it doesn't work:

   "ExceptionlessLoggerProvider": {
      "LogLevel": {
        "Default": "Error"
      }
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureLogging((context, logging) =>
        {
            logging.AddExceptionless(config=>config.SetDefaultMinLogLevel(Exceptionless.Logging.LogLevel.Error)); 
        })
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        });

@niemyjski
Copy link
Member

You'd need to configure the logging levels for what is logging, which is diagnostics and lifetime. I'd look at the full namesapce + type and add it to the normal asp.net core logging config or serilog config if using serilog. The entry for ExceptionlessLoggerProvider is invalid and won't do anything. If you want to log these to your app console but not to us, then you'll need to SetDefaultMinLogLevel like you are doing and or add a configuration entry for the internal log level like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants