Comments (10)
What happens if I want to send the logs to DataDog or any of the other provided sinks? If I wish to now send the data to DDog or Splunk or whatever, I need to hardcode. With the config file method, I can set everything up via the configuration source. The biggest "catch" is that the relevant nuget file needs to be in the bin. (I've never tried manually putting a nuget to a bin, post deployment).
That seems logical to me. Add the nuget package, choose to configure it in code or via config. Adding sinks dynamically isn't something that makes sense IMO.
I think it makes sense to move some things to config but not all of them. For example, I need to be able to detect when a URL is configured so that I can dynamically enable one of those sinks (elastic search for e.g.). Does the configuration model support branches (if statements etc)?
Today I can pass in the application name from the hosting environment but when using config, I need to duplicate that name. There are tradeoffs. Also, I can set breakpoints in code 😄.
That said, send me a PR and we can go back and forth until we meet somewhere in the middle.
from todoapi.
I don't see how you can add new sinks at runtime without also adding a nuget package for that sink (maybe you meant, configure existing sinks?). As for changing log levels at runtime, that's important.
from todoapi.
I don't think it's runtime? The app will need to be restarted manually or via (I think) an OptionsSnapshot
or IOptionsMonitor
? (reloadable configuration?)
from todoapi.
Adding/Changing sinks dynamically I wouldn't want to be in this application. Configuring existing sinks via config is good.
from todoapi.
kewl! that would be fine via the official Serilog Configuration nuget.
So you're happy for a PR to come, enabling this option? (no I haven't done anything yet -> just touching base first, etc).
from todoapi.
Just so I understand, isn't this what's happening here?
from todoapi.
Ah yes! that's correct actually. That's what I was going to do.
<Reads the code .... >
but wait .. i feel like the current setup is incomplete.
see this code here:
this looks like it's a poor persons way of using configuration but then having to still hardcode the code based on some config values.
What happens if I want to send the logs to DataDog or any of the other provided sinks? If I wish to now send the data to DDog or Splunk or whatever, I need to hardcode. With the config file method, I can set everything up via the configuration source. The biggest "catch" is that the relevant nuget file needs to be in the bin. (I've never tried manually putting a nuget to a bin, post deployment).
Here's some code to explain:
- remove this
if (serilogOptions.UseConsole)
{
// https://github.com/serilog/serilog-sinks-async
loggerConfiguration.WriteTo.Async(writeTo =>
writeTo.Console(outputTemplate: serilogOptions.LogTemplate));
}
then add this to appsettings.json
:
- This is any "not-default" sinks that you want to use. It's basically the namespace of the nuget package that isn't in the default Serilog nuget. This is where you would add DataDog, Splunk, etc.. if that's where u want to send data to.
- This is a customizable way to determine what to "enrich" each log, with. It's identical to:
.. except, this way, you can change the enrichment if your want .. versus .. having it hardcoded for every log. Sure, you might say "I want the log-context" value in each log message. But I personally really like picking one (hardcoding) or the other (configuration source) as the one place to define all of this. I just feel like, having this defined in a configuration source gives you more options later on. Say, test environment is playing up ... you can play with the enrichment values here to get more data, if needed.
- Just another key/value that is added with each log message. Or should I say, each log message is "enriched" with this key/value. You have this hardcoded.
- Console sink: pretty simple. No customization required. Just -> log to the console, please.
- Seq sink: this is a bit more complicated but it's where the seq settings will go. Usually it's a form of the sink's "constructor". Can also support arrays in here. Nick Blum has done a great job here, IMO.
and of course, you can keep adding more sinks in here - as required. And different environments (dev/test/prod) could of course have different sinks and/or different log levels, etc.
I hope this makes any sense, at all 😊
from todoapi.
Added draft PR #62 . Not sure if you get notifications for draft PR's.
from todoapi.
I've decided to swap out serilog in favor of the otel logging pipeline.
from todoapi.
okay - i have more to learn, it seems! looking forward to seeing what/why/etc :) kewl!
from todoapi.
Related Issues (20)
- Open Telemetry Exporters HOT 3
- Question : What does the todo.http file do? HOT 2
- Deploy to *somewhere* HOT 6
- Docker Integration
- Client-side password validation is inaccurate HOT 4
- dotnet ef command fails HOT 1
- Cannot log in: "Signing key is not specified" HOT 2
- What is the advantage of using Otel instead of serilog for logging? HOT 8
- Question about Seq / ES + Kib HOT 4
- Allow "discussions" for this repo? HOT 1
- SameSite.Strict auth cookie
- GRPC Support
- The first run of the application: errors HOT 2
- _Host in the Server project HOT 5
- Upgrade from AddMicrosoftAccount to AddMicrosoftIdentityWebApp
- net8 branch doesn't build HOT 6
- Running the app as multiple startup projects in Visual Studio doesn't work
- Shared Project DTO
- Identity endpoints and authorization HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from todoapi.