question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuring sink via LoggerConfiguration.ReadFrom.Configuration()

See original GitHub issue

I’m probably doing something wrong here, but I cannot get Http sink to work when configuring via the appSettings route. Maybe this is simply not supported?

Step 1: Describe your environment

.NET Core

Step 2: Describe the problem

Steps to reproduce:

  1. Configure sink via IConfigurationRoot
    "Serilog": {
        "MinimumLevel": "Debug",
        "Using": [ "Serilog.Sinks.Http" ],
        "WriteTo": [
            {
                "Name": "Http",
                "Args": { "requestUri": "http://127.0.0.1:38421/" }
            }
     }
  1. Feed above config to (new LoggerConfiguration().ReadFrom.Configuration(...))
  2. Run

Observed results

  • The Http sink is not present in the sinks collection and I receive no sort of error to troubleshoot
  • Same configuration and code works with other sinks such as LiterateConsole
  • The Http sink DOES work if I configure it via .WriteTo.Http(...) but we need per-environment configuration and would like it to work as other sinks

Expected results

  • Expected configuration above to result in a Serilog.Core.Logger instance with an Http sink instance in the _sinks property.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
FantasticFiascocommented, Apr 26, 2017

@nblumhardt you are correct, I got it wrong when describing it as a PR. Your proposed solution is a good one, I will try it out.

I think the initiative of having an alternative solution to the problem is a dead fish in the water. I’ll close the issue.

0reactions
nblumhardtcommented, Apr 26, 2017

@FantasticFiasco the issue you’ve linked is not a PR; I don’t think there is likely to be movement on it for a while as we don’t yet have a proposed design, nor any further feedback. Would implementing a specific extension method here, but marking it [EditorBrowsable(EditorBrowsableState.Hidden)] be a good workaround that doesn’t pollute IntelliSense? Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Example of configuring this sink via LoggerConfiguration ...
ReadFrom.Configuration(config) and appsettings.json when in an ASP.NET Core environment with Visual Studio 2017? Something like this (for ...
Read more >
Customize Serilog configuration after ReadFrom. ...
I want to customize some configuration options before actually applying them. For instance, in Elasticsearch Sink some options are of type Func< ...
Read more >
Serilog logging with .Net Core — Are we configuring it correctly?
Configure the settings for Serilog through the config file. "Serilog": { ... var logger = new LoggerConfiguration().ReadFrom.Configuration(builder.
Read more >
Serilog logging setup & configuration example
Step 3 - Using Serilog. Create a statically accessible Logger configured from AppSettings. Copy Log.Logger = new LoggerConfiguration() .ReadFrom.
Read more >
Reading logger configuration from appsettings.json
With the new Serilog.Settings.Configuration package, ReadFrom.Configuration() lets us pull the same information from appsettings.json .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found