Serilog.Sinks.Http 9.0.0-beta.2

This is a prerelease version of Serilog.Sinks.Http.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Serilog.Sinks.Http --version 9.0.0-beta.2                
NuGet\Install-Package Serilog.Sinks.Http -Version 9.0.0-beta.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.Http" Version="9.0.0-beta.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.Http --version 9.0.0-beta.2                
#r "nuget: Serilog.Sinks.Http, 9.0.0-beta.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Sinks.Http as a Cake Addin
#addin nuget:?package=Serilog.Sinks.Http&version=9.0.0-beta.2&prerelease

// Install Serilog.Sinks.Http as a Cake Tool
#tool nuget:?package=Serilog.Sinks.Http&version=9.0.0-beta.2&prerelease                

Serilog.Sinks.Http - A Serilog sink sending log events over HTTP

Build status CI/CD codecov NuGet Version SemVer compatible NuGet Documentation Join the chat at https://gitter.im/serilog/serilog Help

Package - Serilog.Sinks.Http | Platforms - .NET 4.5/4.6.1, .NET Standard 2.0/2.1

Table of contents


Introduction

This project started out with a wish to send log events to the Elastic Stack. I had prior experience of Elastic Filebeat and didn't like it. I thought the value it added was lower than the complexity it introduced.

Knowing that Serilog.Sinks.Seq existed, and knowing that the code was of really good quality, I blatantly copied many of the core files into this project and started developing a general HTTP sink.

And here we are today. I hope you'll find the sink useful. If not, don't hesitate to open an issue.

Super simple to use

In the following example, the sink will POST log events to http://www.mylogs.com over HTTP. We configure the sink using named arguments instead of positional because historically we've seen that most breaking changes where the result of a new parameter describing a new feature. Using named arguments means that you more often than not can migrate to new major versions without any changes to your code.

ILogger log = new LoggerConfiguration()
  .MinimumLevel.Verbose()
  .WriteTo.Http(requestUri: "https://www.mylogs.com", queueLimitBytes: null)
  .CreateLogger();

log.Information("Logging {@Heartbeat} from {Computer}", heartbeat, computer);

Used in conjunction with Serilog.Settings.Configuration the same sink can be configured in the following way:

{
  "Serilog": {
    "MinimumLevel": "Verbose",
    "WriteTo": [
      {
        "Name": "Http",
        "Args": {
          "requestUri": "https://www.mylogs.com",
          "queueLimitBytes": null
        }
      }
    ]
  }
}

The sink can also be configured to be durable, i.e. log events are persisted on disk before being sent over the network, thus protected against data loss after a system or process restart. For more information please read the wiki.

The sink is batching multiple log events into a single request, and the following hypothetical payload is sent over the network as JSON.

[
  {
    "Timestamp": "2016-11-03T00:09:11.4899425+01:00",
    "Level": "Information",
    "MessageTemplate": "Logging {@Heartbeat} from {Computer}",
    "RenderedMessage": "Logging { UserName: \"Mike\", UserDomainName: \"Home\" } from \"Workstation\"",
    "Properties": {
      "Heartbeat": {
        "UserName": "Mike",
        "UserDomainName": "Home"
      },
      "Computer": "Workstation"
    }
  },
  {
    "Timestamp": "2016-11-03T00:09:12.4905685+01:00",
    "Level": "Information",
    "MessageTemplate": "Logging {@Heartbeat} from {Computer}",
    "RenderedMessage": "Logging { UserName: \"Mike\", UserDomainName: \"Home\" } from \"Workstation\"",
    "Properties": {
      "Heartbeat": {
        "UserName": "Mike",
        "UserDomainName": "Home"
      },
      "Computer": "Workstation"
    }
  }
]

Typical use cases

Producing log events is only half the story. Unless you are consuming them in a matter that benefits you in development or production, there is really no need to produce them in the first place.

Integration with Elastic Stack (formerly know as ELK, an acronym for Elasticsearch, Logstash and Kibana) is powerful beyond belief, but there are many alternatives to get the log events into Elasticsearch.

Send log events from Docker containers

A common solution, given your application is running in Docker containers, is to have stdout (standard output) and stderr (standard error) passed on to the Elastic Stack. There is a multitude of ways to accomplish this, but one using Logspout is linked in the Sample applications chapter.

Send log events to Elasticsearch

The log events can be sent directly to Elasticsearch using Serilog.Sinks.Elasticsearch. In this case you've solved your problem without using this sink, and all is well in the world.

Send log events to Logstash

If you would like to send the log events to Logstash for further processing instead of sending them directly to Elasticsearch, this sink in combination with the Logstash HTTP input plugin is the perfect match for you. It is a much better solution than having to install Filebeat on all your instances, mainly because it involves fewer moving parts.

Sample applications

The following sample applications demonstrate the usage of this sink in various contexts:

The following sample application demonstrate how Serilog events from a Docker container end up in the Elastic Stack using Logspout, without using Serilog.Sinks.Http.

Install via NuGet

If you want to include the HTTP sink in your project, you can install it directly from NuGet.

To install the sink, run the following command in the Package Manager Console:

PM> Install-Package Serilog.Sinks.Http

Contributors

The following users have made significant contributions to this project. Thank you so much!

<table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://jetbrains.com/opensource"><img src="https://avatars.githubusercontent.com/u/878437?v=4?s=100" width="100px;" alt="JetBrains"/><br /><sub><b>JetBrains</b></sub></a><br /><a href="#infra-JetBrains" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td> <td align="center" valign="top" width="14.28%"><a href="https://augustoproiete.net/"><img src="https://avatars.githubusercontent.com/u/177608?v=4?s=100" width="100px;" alt="C. Augusto Proiete"/><br /><sub><b>C. Augusto Proiete</b></sub></a><br /><a href="#financial-augustoproiete" title="Financial">💵</a> <a href="#question-augustoproiete" title="Answering Questions">💬</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=augustoproiete" title="Code">💻</a> <a href="#ideas-augustoproiete" title="Ideas, Planning, & Feedback">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lhaussknecht"><img src="https://avatars.githubusercontent.com/u/140147?v=4?s=100" width="100px;" alt="Louis Haußknecht"/><br /><sub><b>Louis Haußknecht</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=lhaussknecht" title="Code">💻</a> <a href="#ideas-lhaussknecht" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Alhaussknecht" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/rob-somerville"><img src="https://avatars.githubusercontent.com/u/12766610?v=4?s=100" width="100px;" alt="rob-somerville"/><br /><sub><b>rob-somerville</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=rob-somerville" title="Code">💻</a> <a href="#ideas-rob-somerville" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Arob-somerville" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/kvpt"><img src="https://avatars.githubusercontent.com/u/1446221?v=4?s=100" width="100px;" alt="Kevin Petit"/><br /><sub><b>Kevin Petit</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=kvpt" title="Code">💻</a> <a href="#ideas-kvpt" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Akvpt" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/aleksaradz"><img src="https://avatars.githubusercontent.com/u/72725560?v=4?s=100" width="100px;" alt="aleksaradz"/><br /><sub><b>aleksaradz</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=aleksaradz" title="Code">💻</a> <a href="#ideas-aleksaradz" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Aaleksaradz" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/michaeltdaniels"><img src="https://avatars.githubusercontent.com/u/45430678?v=4?s=100" width="100px;" alt="michaeltdaniels"/><br /><sub><b>michaeltdaniels</b></sub></a><br /><a href="#ideas-michaeltdaniels" title="Ideas, Planning, & Feedback">🤔</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/dusse1dorf"><img src="https://avatars.githubusercontent.com/u/37047967?v=4?s=100" width="100px;" alt="dusse1dorf"/><br /><sub><b>dusse1dorf</b></sub></a><br /><a href="#ideas-dusse1dorf" title="Ideas, Planning, & Feedback">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/vaibhavepatel"><img src="https://avatars.githubusercontent.com/u/23142694?v=4?s=100" width="100px;" alt="vaibhavepatel"/><br /><sub><b>vaibhavepatel</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Avaibhavepatel" title="Bug reports">🐛</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=vaibhavepatel" title="Code">💻</a> <a href="#ideas-vaibhavepatel" title="Ideas, Planning, & Feedback">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/KalininAndreyVictorovich"><img src="https://avatars.githubusercontent.com/u/1285535?v=4?s=100" width="100px;" alt="KalininAndreyVictorovich"/><br /><sub><b>KalininAndreyVictorovich</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3AKalininAndreyVictorovich" title="Bug reports">🐛</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=KalininAndreyVictorovich" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/tipasergio"><img src="https://avatars.githubusercontent.com/u/6435956?v=4?s=100" width="100px;" alt="Sergios"/><br /><sub><b>Sergios</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3Atipasergio" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/AntonSmolkov"><img src="https://avatars.githubusercontent.com/u/5318028?v=4?s=100" width="100px;" alt="Anton Smolkov"/><br /><sub><b>Anton Smolkov</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=AntonSmolkov" title="Code">💻</a> <a href="https://github.com/FantasticFiasco/serilog-sinks-http/issues?q=author%3AAntonSmolkov" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Siphonophora"><img src="https://avatars.githubusercontent.com/u/32316111?v=4?s=100" width="100px;" alt="Michael J Conrad"/><br /><sub><b>Michael J Conrad</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=Siphonophora" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/seruminar"><img src="https://avatars.githubusercontent.com/u/35008875?v=4?s=100" width="100px;" alt="Yuriy Sountsov"/><br /><sub><b>Yuriy Sountsov</b></sub></a><br /><a href="#ideas-seruminar" title="Ideas, Planning, & Feedback">🤔</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/yuriy-millen"><img src="https://avatars.githubusercontent.com/u/90191982?v=4?s=100" width="100px;" alt="Yuriy Millen"/><br /><sub><b>Yuriy Millen</b></sub></a><br /><a href="https://github.com/FantasticFiasco/serilog-sinks-http/commits?author=yuriy-millen" title="Code">💻</a> <a href="#ideas-yuriy-millen" title="Ideas, Planning, & Feedback">🤔</a></td> </tr> </tbody> </table>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (88)

Showing the top 5 NuGet packages that depend on Serilog.Sinks.Http:

Package Downloads
Serilog.Sinks.Loki

A Serilog Sink for Grafana's Loki log aggregator

Serilog.Sinks.Logz.Io

Serilog event sink that sends logs to Logz.io.

Serilog.Sinks.Dynatrace

Serilog Sink that sends log events to Dynatrace https://www.dynatrace.com/

Serilog.Builder

Builder with my serilog common settings for use Console, Seq and Splunk sinks.

Serilog.Sinks.LogDNA

Serilog Sink that sends log events to LogDNA https://logdna.com

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on Serilog.Sinks.Http:

Repository Stars
slskd/slskd
A modern client-server application for the Soulseek file sharing network.
DevArchitecture/DevArchitecture
DevArchitecture Backend Project
charlessolar/eShopOnContainersDDD
Fork of dotnet-architecture/eShopOnContainers in full DDD/CQRS design using my own patterns
keremvaris/Sennedjem
Sennedjem CQRS (Command Query Responsibility Segregation) yaklaşımını benimseyen ve SOLID prensiplerini ve Clean Architecture yöntemlerini odaklayan bir yazılım geliştirme alt yapısıdır. RabbitMq, ElasticSearch vb araçlara entegre olmak konusunda çok yeteneklidir.
josephwoodward/Serilog-Sinks-Loki
A Serilog Sink for Loki, Grafana's new Prometheus inspired log aggregator
Version Downloads Last updated
9.0.0 624,637 4/14/2024
9.0.0-beta.2 7,010 3/27/2024
9.0.0-beta.1 43,373 4/12/2023
8.0.0 4,752,627 4/10/2022
8.0.0-beta.11 1,637 2/20/2022
8.0.0-beta.10 2,152 12/18/2021
8.0.0-beta.9 131,835 8/22/2021
8.0.0-beta.8 78,609 8/14/2021
8.0.0-beta.7 280,477 5/10/2021
8.0.0-beta.6 241 5/7/2021
8.0.0-beta.5 223 5/4/2021
8.0.0-beta.4 231 4/29/2021
8.0.0-beta.3 4,398 3/30/2021
8.0.0-beta.2 964 3/15/2021
8.0.0-beta.1 685 3/8/2021
7.3.0-af8c758 10,632 1/23/2021
7.2.0 6,503,803 10/19/2020
7.1.0 167,301 10/18/2020
7.0.1 286,209 8/14/2020
7.0.0 25,847 8/12/2020
7.0.0-package-icon-fix 864 8/13/2020
7.0.0-deterministic-builds 874 8/14/2020
7.0.0-allow-untracked-sources 930 8/14/2020
6.0.0 792,139 5/13/2020
5.2.2-d68646f 1,429 5/8/2020
5.2.1 2,444,318 2/16/2020
5.2.0 1,897,549 4/27/2019
5.1.0 973,379 1/7/2019
5.0.1 494,866 9/24/2018
5.0.1-issue-54-00770 1,278 9/18/2018
5.0.1-durable-file-size-rol... 1,101 11/24/2018
5.0.0 37,633 8/30/2018
5.0.0-beta1-00718 1,216 8/27/2018
4.3.0 583,723 2/1/2018
4.3.0-namespaced-formatter-... 1,478 1/25/2018
4.2.1 480,112 10/11/2017
4.2.0 37,338 8/19/2017
4.1.0 5,258 8/13/2017
4.1.0-array-batch-formatter... 1,304 8/11/2017
4.0.0 23,525 6/17/2017
4.0.0-beta-00385 1,417 6/6/2017
3.1.1 4,940 4/24/2017
3.1.0 3,724 3/12/2017
3.0.0 2,041 3/4/2017
2.0.0 132,092 11/23/2016
1.0.0 7,820 11/2/2016
0.0.9-beta-test-00007 1,975 11/2/2016
0.0.9-beta-test-00006 2,030 11/2/2016