Class ILogAdapterExtensions
Extension methods that can be applied to any ILogAdapter.
Inheritance
Namespace: LaunchDarkly.Logging
Assembly: LaunchDarkly.Logging.dll
Syntax
public static class ILogAdapterExtensions : Object
Methods
Level(ILogAdapter, LogLevel)
Disables log output below the specified level.
Declaration
public static ILogAdapter Level(this ILogAdapter adapter, LogLevel minimumLevel)
Parameters
Type | Name | Description |
---|---|---|
ILogAdapter | adapter | |
LogLevel | minimumLevel |
Returns
Type | Description |
---|---|
ILogAdapter | an ILogAdapter that wraps the original one but filters out log messages of lower levels |
Remarks
This is a decorator that can be applied to any ILogAdapter, either one of the standard ones available in Logs or a custom implementation. Any log messages for a lower level will be immediately discarded; all others will be forwarded to the underlying logging implementation (which may also have other filtering rules of its own).
Examples
// This one will write all log messages to Console.Error, including Debug messages var unfilteredLogging = Logs.ToConsole;
// This one will write only Warn and Error messages var filteredLogging = Logs.ToConsole.Level(Warn);
Logger(ILogAdapter, String)
Convenience method for creating logger instances.
Declaration
public static Logger Logger(this ILogAdapter adapter, string name)
Parameters
Type | Name | Description |
---|---|---|
ILogAdapter | adapter | the ILogAdapter that provides the underlying implementation of logging |
System.String | name | the name for this logger |
Returns
Type | Description |
---|---|
Logger | a logger instance |
Remarks
This is a shortcut for calling WithAdapter(ILogAdapter, String). Application code will not normally use this method; it is used by library code to set up individual named loggers that a library will log to.