All Projects → datalust → serilog-sinks-seq

datalust / serilog-sinks-seq

Licence: Apache-2.0 License
A Serilog sink that writes events to the Seq structured log server

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to serilog-sinks-seq

serilog-sinks-slackclient
Slack Sink for Serilog
Stars: ✭ 24 (-81.82%)
Mutual labels:  serilog-sink, serilog
serilog-sinks-rabbitmq
Serilog Sink for RabbitMq
Stars: ✭ 49 (-62.88%)
Mutual labels:  serilog-sink, serilog
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (-18.18%)
Mutual labels:  serilog-sink, serilog
serilog-sinks-xamarin
A Serilog sink that writes events to Xamarin mobile targets
Stars: ✭ 46 (-65.15%)
Mutual labels:  serilog-sink, serilog
seq-forwarder
Local collection and reliable forwarding of log data to Seq
Stars: ✭ 43 (-67.42%)
Mutual labels:  seq, serilog
Analogy.LogViewer
A customizable Log Viewer with ability to create custom providers. Can be used with C#, C++, Python, Java and others
Stars: ✭ 172 (+30.3%)
Mutual labels:  serilog
Serilog.Sinks.Postgresql.Alternative
Serilog.Sinks.Postgresql.Alternative is a library to save logging information from https://github.com/serilog/serilog to https://www.postgresql.org/.
Stars: ✭ 29 (-78.03%)
Mutual labels:  serilog
ArchitectNow.ApiStarter
Sample ASP.NET Core 2 API Setup used by ArchitectNow for corresponding workshop presentations
Stars: ✭ 35 (-73.48%)
Mutual labels:  serilog
honeycomb
本项目用于验证一系列开源项目
Stars: ✭ 13 (-90.15%)
Mutual labels:  serilog
arcus.observability
Observability with Microsoft Azure in a breeze.
Stars: ✭ 24 (-81.82%)
Mutual labels:  serilog
CleanArchitecture-Template
This is a solution template for Clean Architecture and CQRS implementation with ASP.NET Core.
Stars: ✭ 60 (-54.55%)
Mutual labels:  serilog
TelephoneDirectory
microservices-> .net 6, golang - Docker, Ocelot, RabbitMq, MassTransit, mssql, postgresql, elasticsearch, kibana, jwt
Stars: ✭ 40 (-69.7%)
Mutual labels:  serilog
serilog-sinks-richtextbox
A Serilog sink that writes log events to a WPF RichTextBox control with colors and theme support
Stars: ✭ 48 (-63.64%)
Mutual labels:  serilog
seq-cheat-sheets
Cheat sheets for Seq filtering and querying syntax
Stars: ✭ 49 (-62.88%)
Mutual labels:  seq
Sitko.Core
Sitko.Core is a set of libraries to help build .NET Core applications fast
Stars: ✭ 46 (-65.15%)
Mutual labels:  serilog
serilogj
A direct Java port of .NET's Serilog
Stars: ✭ 34 (-74.24%)
Mutual labels:  serilog
Seq.Client.EventLog
Writes Windows Event Log entries to Seq
Stars: ✭ 25 (-81.06%)
Mutual labels:  seq
serilog-sinks-browserhttp
Serilog sink for client-side Blazor, with matching ASP.NET Core server relay
Stars: ✭ 36 (-72.73%)
Mutual labels:  serilog
seq-tickets
Issues, design discussions and feature roadmap for the Seq log server
Stars: ✭ 81 (-38.64%)
Mutual labels:  seq
ASPNETcoreAngularJWT
Angular in ASP.NET Core with JWT solution by systemjs
Stars: ✭ 48 (-63.64%)
Mutual labels:  serilog

Serilog.Sinks.Seq Build status NuGet Join the chat at https://gitter.im/serilog/serilog

A Serilog sink that writes events to the Seq structured log server. Supports .NET 4.5+, .NET Core, and platforms compatible with the .NET Platform Standard 1.1 including Windows 8 & UWP, Windows Phone and Xamarin.

Package Logo

Getting started

Install the Serilog.Sinks.Seq package from Visual Studio's NuGet console:

PM> Install-Package Serilog.Sinks.Seq

Point the logger to Seq:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Seq("http://localhost:5341")
    .CreateLogger();

And use the Serilog logging methods to associate named properties with log events:

Log.Error("Failed to log on user {ContactId}", contactId);

Then query log event properties like ContactId from the browser:

Query in Seq

When the application shuts down, ensure any buffered events are propertly flushed to Seq by disposing the logger or calling Log.CloseAndFlush():

Log.CloseAndFlush();

The sink can take advantage of Seq's API keys to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the apiKey parameter of WriteTo.Seq().

XML <appSettings> configuration

To adjust the Seq server URL at deployment time, it's often convenient to configure it using XML <appSettings>, in the App.config or Web.config file.

Before Serilog can be configured using XML, the Serilog.Settings.AppSettings package must be installed and enabled using the LoggerConfiguration:

Log.Logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

When XML is used for configuration, it's not necessary to include the WriteTo.Seq() method. It is important however that the Serilog.Sinks.Seq.dll assembly is present alongside the app's binaries.

The settings typically included are:

<configuration>
  <appSettings>
    <add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
    <add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
    <add key="serilog:write-to:Seq.apiKey" value="[optional API key here]" />

Serilog's XML configuration has several other capabilities that are described on the Serilog wiki.

JSON appsettings.json configuration

To use the Seq sink with Microsoft.Extensions.Configuration, for example with ASP.NET Core or .NET Core, use the Serilog.Settings.Configuration package. First install that package if you have not already done so:

Install-Package Serilog.Settings.Configuration

Instead of configuring the Seq sink directly in code, call ReadFrom.Configuration():

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

var logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();

In your appsettings.json file, under the Serilog node, :

{
  "Serilog": {
    "WriteTo": [
      { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } }
    ]
  }
}

See the XML <appSettings> example above for a discussion of available Args options.

Dynamic log level control

The Seq sink can dynamically adjust the logging level up or down based on the level associated with an API key in Seq. To use this feature, create a LoggingLevelSwitch to control the MinimumLevel, and pass this in the controlLevelSwitch parameter of WriteTo.Seq():

var levelSwitch = new LoggingLevelSwitch();

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .WriteTo.Seq("http://localhost:5341",
                 apiKey: "yeEZyL3SMcxEKUijBjN",
                 controlLevelSwitch: levelSwitch)
    .CreateLogger();

The equivalent configuration in XML (Serilog 2.6+) is:

<configuration>
  <appSettings>
    <!-- declare the switch -->
    <add key="serilog:level-switch:$controlSwitch" value="Information" />
    <!-- use it to control the root logger -->
    <add key="serilog:minimum-level:controlled-by" value="$controlSwitch" />
    <add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
    <add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
    <add key="serilog:write-to:Seq.apiKey" value="yeEZyL3SMcxEKUijBjN" />
    <!-- give the sink access to the switch -->
    <add key="serilog:write-to:Seq.controlLevelSwitch" value="$controlSwitch" />

The equivalent configuration in JSON is:

{
    "Serilog":
    {
        "LevelSwitches": { "$controlSwitch": "Information" },
        "MinimumLevel": { "ControlledBy": "$controlSwitch" },
        "WriteTo":
        [{
            "Name": "Seq",
            "Args":
            {
                "serverUrl": "http://localhost:5341",
                "apiKey": "yeEZyL3SMcxEKUijBjN",
                "controlLevelSwitch": "$controlSwitch"
            }
        }]
    }
}

For further information see the Seq documentation.

Troubleshooting

Nothing showed up, what can I do?

If events don't appear in Seq after pressing the refresh button in the filter bar, either your application was unable to contact the Seq server, or else the Seq server rejected the log events for some reason.

Server-side issues

The Seq server may reject incoming events if they're missing a required API key, if the payload is corrupted somehow, or if the log events are too large to accept.

Server-side issues are diagnosed using the Seq Ingestion Log, which shows the details of any problems detected on the server side. The ingestion log is linked from the Settings > Diagnostics page in the Seq user interface.

Client-side issues

If there's no information in the ingestion log, the application was probably unable to reach the server because of network configuration or connectivity issues. These are reported to the application through Serilog's SelfLog.

Add the following line after the logger is configured to print any error information to the console:

Serilog.Debugging.SelfLog.Enable(Console.Error);

If the console is not available, you can pass a delegate into SelfLog.Enable() that will be called with each error message:

Serilog.Debugging.SelfLog.Enable(message => {
    // Do something with `message`
});

Troubleshooting checklist

  • Check the Seq Ingestion Log, as described in the Server-side issues section above.
  • Turn on the Serilog SelfLog as described above to check for connectivity problems and other issues on the client side.
  • Make sure your application calls Log.CloseAndFlush(), or disposes the root Logger, before it exits - otherwise, buffered events may be lost.
  • If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated "hard" if the close button in the title bar is used, so events buffered for sending to Seq may be lost if you use it.
  • Raise an issue, ask for help on the Seq support forum or email [email protected].
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].