C
C#7mo ago
Denis

✅ Setting up centralized logging for desktop apps

I wish to setup centralized logging using OpenTelemetry. I'm lost on exporting structured logs from a desktop application. I have a .NET Server managing database access that exposes gRPC endpoints for clients. I have .NET desktop Clients (specifically WPF, but this should be irrelevant) that connect to the server via gRPC. The server and clients shall be installed on-premises; serving these as a cloud SaaS is a future prospect. I've managed to setup opentelemetry logging for my WPF client; however, I'm clueless as to where and how I should export the collected data. From my understanding, logs from both the server and clients should be exported to a third service specifically for handling logs. Is this a good approach? My initial idea was to send logs from clients to the server and then have the server handle the dirty work. It stemmed from the fact that most guides on setting up OT are for ASP.NET Core applications, that just add an endpoint for sending the collected logs and traces. To what "system" or service should I export my logs to? I wish to keep it small and simple, handling around 20 clients and a server and storing logs and metrics for 30 days.
11 Replies
Pobiega
Pobiega7mo ago
To what "system" or service should I export my logs to?
You have some options. Seq is very good, but you could also set up your own ELK (Elastic, LogStash, Kibana) stack. Loki could also be an option.
My initial idea was to send logs from clients to the server and then have the server handle the dirty work.
Good. Smart thinking. Don't let the clients talk directly to the log service, that way leads madness and security/data authenticity issues.
Denis
DenisOP7mo ago
Won't ELK be overkill for so few clients? I'd really want an opensource, easy to setup solution. Hopefully that isn't unrealistic So from what I've read, Seq is not an option due to its commercial licensing
Pobiega
Pobiega7mo ago
Maybe Loki + Grafana then?
Denis
DenisOP7mo ago
Loki is for logs, prometheus for metrics, right?
Pobiega
Pobiega7mo ago
correct
Denis
DenisOP7mo ago
And coming back to the clients. You say that sending logs through the server is a better idea. Thus, I do not setup opentelemetry in my clients, and instead log via some API endpoint on the server, right? Client ---- logs -----> Server ----- logs ----> Loki ----> grafana
Pobiega
Pobiega7mo ago
well, you have options you could set up opentelemetry in the client, and set up a "receiver" on your server that just forwards it to Loki or you write a sink that does the same I've not used OpenTelemetry myself very much yet, so don't know all the details about it but for client logging, you normally want to add a bunch of things like auth so you can verify what client sent the logs etc dunno how easily the default OT stuff handles that
Denis
DenisOP7mo ago
that makes sense... I'm unfamiliar with the term "sink". That would be the output target of my ILogger? E.g., ConsoleLogger?
Pobiega
Pobiega7mo ago
Yeah, the term comes specifically from Serilog So much like you do AddConsole in m.e.l, you could add your own ext method to register your own sink I dont know what m.e.l calls them
Denis
DenisOP7mo ago
Alright, this was very helpful! Thanks a lot
Pobiega
Pobiega7mo ago
"logging providers" seems to be their term Not sure i like that, they dont provide, they handle
Want results from more Discord servers?
Add your server