Show / Hide Table of Contents

Class Logger

A basic logger facade that delegates to an underlying output implementation.

Inheritance
System.Object
Logger
Namespace: LaunchDarkly.Logging
Assembly: LaunchDarkly.Logging.dll
Syntax
public sealed class Logger : Object
Remarks

Code that generates log output will send it through this class. What happens to the output depends on the ILogAdapter that was used to create the Logger.

The logger has output methods for each of the levels defined in LogLevel. Each can take either a simple string, or a format string with variable parameters in the syntax used by System.String.Format(System.String,System.Object). For efficiency (to avoid unnecessarily creating varargs arrays), each method has four overloads: one simple string, format with one parameter, format with two parameters, and format with an arbitrary number of parameters.

Methods

Debug(Object)

Writes a message at Debug level.

Declaration
public void Debug(object message)
Parameters
Type Name Description
System.Object message

the message; if null, nothing is logged

Debug(String, Object)

Writes a message at Debug level with one parameter.

Declaration
public void Debug(string format, object param)
Parameters
Type Name Description
System.String format

the format string; if null, nothing is logged

System.Object param

the parameter

Debug(String, Object, Object)

Writes a message at Debug level with two parameters.

Declaration
public void Debug(string format, object param1, object param2)
Parameters
Type Name Description
System.String format

the format string; if null, nothing is logged

System.Object param1

the first parameter

System.Object param2

the second parameter

Debug(String, Object[])

Writes a message at Debug level with any number of parameters.

Declaration
public void Debug(string format, params object[] allParams)
Parameters
Type Name Description
System.String format

the format string; if null, nothing is logged

System.Object[] allParams

the parameters

Error(Object)

Writes a message at Error level.

Declaration
public void Error(object message)
Parameters
Type Name Description
System.Object message

the message

error(String, Object)

Writes a message at Error level with one parameter.

Declaration
public void error(string format, object param)
Parameters
Type Name Description
System.String format

the format string

System.Object param

the parameter

Error(String, Object, Object)

Writes a message at Error level with two parameters.

Declaration
public void Error(string format, object param1, object param2)
Parameters
Type Name Description
System.String format

the format string

System.Object param1

the first parameter

System.Object param2

the second parameter

Error(String, Object[])

Writes a message at Error level with any number of parameters.

Declaration
public void Error(string format, params object[] allParams)
Parameters
Type Name Description
System.String format

the format string

System.Object[] allParams

the parameters

Info(Object)

Writes a message at Info level.

Declaration
public void Info(object message)
Parameters
Type Name Description
System.Object message

the message

Info(String, Object)

Writes a message at Info level with one parameter.

Declaration
public void Info(string format, object param)
Parameters
Type Name Description
System.String format

the format string

System.Object param

the parameter

Info(String, Object, Object)

Writes a message at Info level with two parameters.

Declaration
public void Info(string format, object param1, object param2)
Parameters
Type Name Description
System.String format

the format string

System.Object param1

the first parameter

System.Object param2

the second parameter

Info(String, Object[])

Writes a message at Info level with any number of parameters.

Declaration
public void Info(string format, params object[] allParams)
Parameters
Type Name Description
System.String format

the format string

System.Object[] allParams

the parameters

IsEnabled(LogLevel)

Tests whether log output for a certain level is at least potentially visible.

Declaration
public bool IsEnabled(LogLevel level)
Parameters
Type Name Description
LogLevel level

a log level

Returns
Type Description
System.Boolean

true if this level is potentially visible

Remarks

Generally, any desired level filtering should be set up in the initial logging configuration, and code that generates log messages should simply call methods like Info(Object) without having to know whether that particular level is enabled or is being filtered out. However, if some kind of log message is particularly expensive to compute, you may call IsEnabled; a false value means you can skip trying to log any message at that level.

Another approach is to generate any computationally expensive output lazily, such as by using the methods in LogValues.

SubLogger(String)

Creates a logger instance derived from this instance.

Declaration
public Logger SubLogger(string nameSuffix)
Parameters
Type Name Description
System.String nameSuffix

will be appended to the current logger's name, separated by a period, to create the new logger's name

Returns
Type Description
Logger

a new logger instance

Warn(Object)

Writes a message at Warn level.

Declaration
public void Warn(object message)
Parameters
Type Name Description
System.Object message

the message

Warn(String, Object)

Writes a message at Warn level with one parameter.

Declaration
public void Warn(string format, object param)
Parameters
Type Name Description
System.String format

the format string

System.Object param

the parameter

Warn(String, Object, Object)

Writes a message at Warn level with two parameters.

Declaration
public void Warn(string format, object param1, object param2)
Parameters
Type Name Description
System.String format

the format string

System.Object param1

the first parameter

System.Object param2

the second parameter

Warn(String, Object[])

Writes a message at Warn level with any number of parameters.

Declaration
public void Warn(string format, params object[] allParams)
Parameters
Type Name Description
System.String format

the format string

System.Object[] allParams

the parameters

WithAdapter(ILogAdapter, String)

Creates a named logger instance using the specified adapter.

Declaration
public static Logger WithAdapter(ILogAdapter adapter, string name)
Parameters
Type Name Description
ILogAdapter adapter

the ILogAdapter that defines the actual logging implementation

System.String name

the name for this logger

Returns
Type Description
Logger

a new logger instance

Remarks

This method (or the equivalent shortcut adapter.Logger(name)) is called by library code to acquire a Logger instance that it will write output to.

In This Article
Back to top Generated by DocFX