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.

Add the option to log to the console

See original GitHub issue

Add the sink to let Serilog log to the console: Serilog.Sinks.Console. This is especially useful in environments like Kubernetes where you want to do logshipping/distributed logging. It can be off by default, although that would not be my preference.

The recently added logging to the DB is definitely not my preferred way to keep logs. You lose the option to do structured logging as well. I would vote to make this optional as well. I want to be able to do log-shipping to off-site services like Seq/Cloudwatch/Datadog. Currently there is no way to scrape those logs, except from file, but that requires write access to the file-system which in a Docker environment isn’t desirable either. We also need to revisit the current way of logging to enable structured logging so that services like seq and cloudwatch can do structured queries on certain properties. Adding distributed tracing with OpenTracing/Jaeger is certainly another thing we need to take a look at.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
bravecobracommented, Dec 23, 2019

I wouldn’t want to add dependencies that are opinionated and stick to the basics ones. We don’t want to impose any preference but leave open the option to add more by just referencing the sink required and changing the configuration. Actually, I’d leave the console to be the only one enabled. Any other option as logging is a very opinionated topic. As mentioned before even file logging might not be desirable (especially in docker env’s ). Looking at the Provided-Sinks of Serilog, I’d go with just

  • Serilog.Sinks.Console (enabled and configured by default)
  • Serilog.Sinks.Debug (enabled in Development env only for VS debug reasons, in appsettings.Development.json)
  • Serilog.Sinks.Async (disabled, but referenced)
  • Serilog.Sinks.File (disabled, but referenced and sample configuration)
  • Serilog.Sinks.MSSqlServer (disabled, but referenced and sample configuration) as we now have a way of logging to the database for those who want it. There are far more powerful tools available to parse and search logs than the one we have in this code. Take a look at loggly, seq, cloudwatch, datadog, etc

People can then choose/configure their own by adding the reference and updating their appsettings.json.

We should choose the do logging earlier as well as specified in Serilog’s example to catch EF migration errors, which are not logged to sql at the moment (as it crashes beforehand): https://github.com/serilog/serilog-docker/blob/master/web-sample/src/Program.cs, which should be a straight forward change.

0reactions
skorubacommented, Jan 1, 2020

According to @bravecobra PR added into dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

console: log() method - Web APIs | MDN
The console.log() method outputs a message to the web console. The message may be a single string (with optional substitution values), ...
Read more >
Adding console.log to every function automatically
Here's some Javascript which replaces adds console. log to every function in Javascript; Play with it on Regex101: $re = "/function (.
Read more >
Log messages in the Console tool - Microsoft Edge
Press Ctrl+Shift+J (Windows, Linux) or Command+Option+J (macOS). DevTools opens, with the Console open in main toolbar.
Read more >
Log messages in the Console - Chrome Developers
Open the Command Menu, start typing Console , select the Show Console Panel command, and then press Enter . Click the Log Warning...
Read more >
JavaScript Console.log() Example – How to Print to the ...
The first log will print the properties within the user object. The second will identify the object as "user" and print the properties...
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