Closed ddshpak closed 4 years ago
Hi and sorry for the very delayed response. Yes, at the moment, the LogglyConfiguration object should be built/composed to pass that info in.
I saw that you have created a PR (https://github.com/serilog/serilog-sinks-loggly/pull/31) and will look into it.
Is https://github.com/serilog/serilog-settings-configuration a viable solution for this (instead of changing the public interface of the extension method)?
I've seen from https://github.com/serilog/serilog-settings-configuration/issues/58 that it's not yet possible to configure complex objects as args, so the list of args would need to be flattened.
Hi @MiguelAlho,
My understanding of https://github.com/serilog/serilog-settings-configuration is that it will take any settings it finds in the supplied JSON, and inject them as constructor parameters...but, as you point out, it doesn't support complex objects as arguments.
I didn't want to flatten the entire LogglyConfiguration
object into simple-valued constructor arguments, so I took the approach of just adding the three that seemed the most important: the customer token (absolutely required), the tags (very valuable), and the endpoint (probably not needed, to be honest).
With these new arguments in place, https://github.com/serilog/serilog-settings-configuration does the rest of the work of actually parsing the JSON and passing in the correct arguments. The change to the public interface is backwards-compatible (the new arguments have default values).
I'm quite new to Serilog, so I might be missing something that should be obvious. If there's a better way to leverage the existing configuration code, I'd be happy to try to implement it; I might just need to be pointed in the right direction.
Thanks!
I tried building a sample using serilog-settings-configuration, but it unfortunately does not support complex objects. If it did, the sample you provided above would have been enough. It may be better to include support for the params, as you have in your PR.
Hi, @dshpak-iq , @MiguelAlho. This should work with 3.0
+ of the Serilog.Settings.Configuration
package.
I've added a sample project in the features/jsonConfig branch that can be used to test things like this out. At the moment, Using the sample, I can send messages to loggly using just the appsettings.json file to configure the logger, though I'm not testing the durable logger just yet.
PR: https://github.com/serilog/serilog-sinks-loggly/pull/53 to put this in the dev branch
I haven't been able to find a good way to do configuration-driven setup of the Loggly sink in a .NET Core app. It doesn't look like I can specify anything like
because that fails with
System.InvalidOperationException: Argument value should be of type Action<>.
. And in a .NET Core app, I don't have anapp.config
file, so I can't use loggly-csharp-configuration's XML-based configuration (as far as I know).Am I missing something? Or is the current state of affairs such that I need to do programmatic configuration of Loggly in a .NET Core application?