Class ILoggerFactoryExtensions
This extension class provides methods simplify the configuration of Microsofts ILoggerFactory.
Inheritance
Namespace: TeleScope.Logging.Extensions.Serilog
Assembly: TeleScope.Logging.Extensions.Serilog.dll
Syntax
public static class ILoggerFactoryExtensions : object
Methods
| Improve this Doc View SourceAddSerilogConsole(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. |
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. |
UseFormatter(ILoggerFactory, ITextFormatter)
Applies a different text formatter for the logging of object data.
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. |
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. |
UseTemplate(ILoggerFactory, String)
Applies a template string to structure log messages.
{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. |