GithubHelp home page GithubHelp logo

serilog-archive / serilog-sinks-literate Goto Github PK

View Code? Open in Web Editor NEW
22.0 5.0 7.0 219 KB

Deprecated: now a part of https://github.com/serilog/serilog-sinks-console

License: Apache License 2.0

PowerShell 28.63% C# 71.37%

serilog-sinks-literate's Introduction

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

An alternative colored console sink for Serilog that uses a literate programming-inspired presentation to showcase the structure/type of event data. This is in contrast with the ColoredConsole sink that uses color predominantly to emphasise an event's level.

Screenshot

This package is being retired

The features of this sink have now been merged into the default Serilog console sink. We recommend using the console sink instead.

Getting started

Install the Serilog.Sinks.Literate package from NuGet:

Install-Package Serilog.Sinks.Literate

To configure the sink in C# code, call WriteTo.LiterateConsole() during logger configuration:

var log = new LoggerConfiguration()
    .WriteTo.LiterateConsole()
    .CreateLogger();
    
Log.Information("This will be written to the literate console");

XML <appSettings> configuration

To use the literate console sink with the Serilog.Settings.AppSettings package, first install that package if you haven't already done so:

Install-Package Serilog.Settings.AppSettings

Instead of configuring the logger in code, call ReadFrom.AppSettings():

var log = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

In your application's App.config or Web.config file, specify the literate sink assembly and required path format under the <appSettings> node:

<configuration>
  <appSettings>
    <add key="serilog:using" value="Serilog.Sinks.Literate" />
    <add key="serilog:write-to:LiterateConsole" />
  </appSettings>
</configuration>

JSON appsettings.json configuration

To use the rolling file 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 literate console 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": "LiterateConsole" }
    ]
  }
}

Copyright © 2016 Serilog Contributors - Provided under the Apache License, Version 2.0.

serilog-sinks-literate's People

Contributors

adamchester avatar dahlbyk avatar merbla avatar nblumhardt avatar optical avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

serilog-sinks-literate's Issues

Allow colour output to interop with other console writers

I often use this sink to get great readable console output during my unit tests. However, I also often have multiple test threads running at the same time. This causes the console output to be interleaved between the multiple threads, making it hard to read and understand what just happened. Sometimes the colours are in the wrong place... sometimes the text from one process is interleaved with text from the literate sink.

One common way to solve this issue is to simply allow the caller/user to provide an object which can be used as the lock. All console writers share this lock object instance and this ensures that a each log event is written to the console write as an atomic operation.

The downside of course is that each thread may end up getting blocked longer and more often, however at least now the console output makes sense, and the user explicitly decided to opt in to this anyway by providing the locks.

Support LoggingLevelSwitch?

Hi,

Are there any plans to support LoggingLevelSwitch?
Unless I'm missing something, not passing restrictedToMinimumLevel will default to verbose.

Thanks in advance,
Jean

DNXCore50 Compatible?

Could you update README.md with informmation wheter it's compatible and if not whether you plan to add it?

Color palette poor under Linux on Docker on Windows - Theme Support?

Running the Docker on Windows beta; the dark gray brackets are not visible, blue Booleans and null are unreadable, and the overall color scheme is washed out and dull.

image

Since many terminals have different color capabilities or renderings, and just about every programmer has different theme preferences, why don't we add editor-style syntax highlighting themes here?

Switching to ANSI color codes is probably the way to go; it'd be nice to provide a 256-color palette since most terminals do or will support it.

Some examples of the kinds of things it'd be cool to support:

The default would probably remain as-is, and use the standard system console colors; color codes should only be written when writing to a terminal so that they don't show up in piped output.

Log.Logger = new LoggerConfiguration()
    .WriteTo.LiterateConsole(theme: LiterateConsoleTheme.VSCode)
    .CreateLogger();

LiterateConsoleTheme would be a user-constructable class; it may be necessary to make it abstract and provide concrete SystemLiterateConsoleTheme and AnsiLiterateConsoleTheme or similar.

Needs a more detailed design, but should be approachable.

Wrap Serilog.Sinks.Console 3.0

The upcoming Serilog.Sinks.Console version 3.0 is a superset of this sink. We should direct visitors to it, and update this package to be a simple wrapper for the new one.

  • Implement WriteTo.LiterateConsole in terms of WriteTo.Console
  • Update README.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.