Search Results for

    Show / Hide Table of Contents

    Class ILoggerFactoryExtensions

    This extension class provides methods simplify the configuration of Microsofts ILoggerFactory.

    Inheritance
    System.Object
    ILoggerFactoryExtensions
    Namespace: TeleScope.Logging.Extensions.Serilog
    Assembly: TeleScope.Logging.Extensions.Serilog.dll
    Syntax
    public static class ILoggerFactoryExtensions : object

    Methods

    | Improve this Doc View Source

    AddSerilogConsole(ILoggerFactory)

    Adds the console sink to the logger factory.

    Declaration
    public static ILoggerFactory AddSerilogConsole(this ILoggerFactory factory)
    Parameters
    Type Name Description
    ILoggerFactory factory

    The calling instance.

    Returns
    Type Description
    ILoggerFactory

    The calling instance.

    | Improve this Doc View Source

    AddSerilogFile(ILoggerFactory, String)

    Adds the file sink to the logger factory.

    Declaration
    public static ILoggerFactory AddSerilogFile(this ILoggerFactory factory, string file)
    Parameters
    Type Name Description
    ILoggerFactory factory

    The calling instance.

    System.String file

    The file, where the log will be stored.

    Returns
    Type Description
    ILoggerFactory

    The calling instance.

    | Improve this Doc View Source

    UseFormatter(ILoggerFactory, ITextFormatter)

    Applies a different text formatter for the logging of object data. The following sample shows that the default formatter from Serilog is the CompactJsonFormatter.

    private static ITextFormatter textFormatter = new CompactJsonFormatter();
    Declaration
    public static ILoggerFactory UseFormatter(this ILoggerFactory factory, ITextFormatter formatter)
    Parameters
    Type Name Description
    ILoggerFactory factory

    The calling instance.

    ITextFormatter formatter
    Returns
    Type Description
    ILoggerFactory

    The calling instance.

    | Improve this Doc View Source

    UseLevel(ILoggerFactory, LogLevel)

    Applies a minimum log level.

    Declaration
    public static ILoggerFactory UseLevel(this ILoggerFactory factory, LogLevel minimumLevel)
    Parameters
    Type Name Description
    ILoggerFactory factory

    The calling instance.

    LogLevel minimumLevel

    The minumum log level as enum LogLevel.

    Returns
    Type Description
    ILoggerFactory

    The calling instance.

    | Improve this Doc View Source

    UseTemplate(ILoggerFactory, String)

    Applies a template string to structure log messages. The following sample shows how the default template is structured.

    {Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] [{SourceContext:l}] {Message}{NewLine}{Exception}
    Declaration
    public static ILoggerFactory UseTemplate(this ILoggerFactory factory, string newTemplate)
    Parameters
    Type Name Description
    ILoggerFactory factory

    The calling instance.

    System.String newTemplate

    The new template string.

    Returns
    Type Description
    ILoggerFactory

    The calling instance.

    • GITHUB
    • Improve this Doc
    • View Source
    ☀
    ☾
    In This Article
    Back to top
    Copyright 2020-2022 TeleScope-dotnet. Generated by DocFX.
    ☀
    ☾