Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What logging framework is better to use in F# code [closed]

Tags:

I need to add logging to my F# project. For C# code we used: Log4net or NLog (possible two of the most popular logging frameworks for .Net).

What is the best choice to use in F# code? I mean, is there any specific logging framework written for usage in F# code?

like image 438
Vitaliy Avatar asked Mar 10 '11 09:03

Vitaliy


People also ask

Which is the best logging framework in Java?

One of the most popular solutions for the Java world is the Apache Log4j 2 framework. Maintained by the Apache Foundation, Log4j 2 is an improvement on the original Log4j, which was the most popular logging framework in Java for many years.

Which logging framework is best for spring boot?

Spring Boot's default logging framework is Logback. Your application code should interface only with the SLF4J facade so that it's easy to switch to an alternative framework if necessary. Log4j2 is newer and claims to improve on the performance of Logback.

Which is the best logging framework .NET core?

NLog. NLog is one of the most popular, and one of the best-performing logging frameworks for . NET. Setting up NLog is fairly simple.

Why should we use logging framework?

Logging frameworks offer flexibility and prevent you from reinventing the wheel.


2 Answers

The Logary library

https://github.com/logary/logary

I'm the author of Logary, which supports logging, metrics and distributed tracing for .Net Core.

Targets include: TextWriter, Console, LiterateConsole, Debugger, GCP Pub/Sub, GCP BigQuery, GCP Stackdriver, Jaeger, TCP (Shipper), UDP (Shipper), ZeroMQ (Shipper) Elasticsearch, Graphite/statsd, elmah.io, Aliyun, Azure ApplicationInsights, Mixpanel (commercial), OpsGenie (commercial), Server-sent-events (web push).

Further, you can expose a HTTP server for Proemetheus to scrape with Logary.Prometheus.

It also has a Dash service that supports real-time push of logs to your web browser.

Further, Logary Rutta is a sidecar container implementation or stand-alone log router for the cloud-native era.

Logary JS is a logging and metrics library for JavaScript that can ship into Logary Rutta on the server side, from where you can then furthr the logs to any of the available targets.

Logary Facade is an Apache 2-licensed facade you can copy-n-paste into all your C# and F# libraries and get high-quality console logging with.

Logary is written in F# for F# primarily.

Install-Package Logary 

docs here

All of the above is free to use for non-commercial purposes. You can see the different licenses here.

like image 131
Henrik Avatar answered Sep 21 '22 18:09

Henrik


As far as I know, they're the same for F#, i.e. there's nothing F# specific about them (whether good or bad). Aside from configuration, usage is pretty much the same for all logging libraries.

What you might want to add is printf-enabled logging, so instead of logger.DebugFormat("Hello {0}", "world") or logger.Debug(sprintf "Hello %s" "world") you can just do logger.Debugf "Hello %s" "world". Use type extensions and kprintf to do this.

like image 38
Mauricio Scheffer Avatar answered Sep 22 '22 18:09

Mauricio Scheffer