Tailed
  • Tailed
  • How it works
  • Zero-Install Web Tailer
    • Getting Started
    • Limitations
  • Command Line Tool
    • Installation
    • Reference
  • Client Libraries
    • .NET
    • Node JS
  • Colorization
    • Standard Rules
    • Custom Rules
  • Roadmap
  • GitHub Repositories
Powered by GitBook
On this page
  • Setup
  • Basic Usage
  • Customization Options
  1. Client Libraries

.NET

How to instrument Tailed from .NET with just two lines of code.

Setup

Install the Tailed.Console nuget package:

dotnet add package Tailed.Console

Basic Usage

You will need to create a new ConsoleSession and then start it:

using Tailed.Console;

// The magic two lines!
await using var session = new ConsoleSession();
session.Start();

Console.WriteLine("This will be streamed to tailed.live");

// This is optional - StopAsync() will be called when disposing the session, if it
// hasn't been called already.
await session.StopAsync();
Console.WriteLine("This won't be streamed to tailed.live");

Choose the right point at which to start the ConsoleSession. For example, if you're asking the user for credentials or a connection string, you'll want to start the session after that point so you don't stream those details to everyone viewing the session.

Customization Options

The constructor on the ConsoleSession allows you to customize:

  1. A custom hostname to use in the session URL (instead of tailed.live).

If you choose to call StopAsync() yourself, an override exists that allows you to specify the number of milliseconds to wait to allow buffers to be flushed. This defaults to 2000 ms.

PreviousReferenceNextNode JS

Last updated 1 year ago

Any logging framework that has a console output (e.g. or ) can be used together with the above configuration code.

Whether only ANSI colors are honored (the default) or whether Console.ForegroundColor and Console.BackgroundColor should also be honored. More fine-grained control of color can be achieved using ANSI. The nuget package is recommended to facilitate colorization. Ensure you're using a console window that handles ANSI colors (e.g. Windows Terminal as opposed to the traditional Command Prompt).

Microsoft.Extensions.Logging.Console
Serilog.Sinks.Console
Pastel