Table of Contents

Class Log

Namespace: Casewhere.Infrastructure.Logging
Assembly: Casewhere.Infrastructure.Logging.dll

Provides methods for writing log.

public static class Log

Inheritance

objectLog

Inherited Members

object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Extension Methods

ObjectExtension.ConvertToBsonValue(object)

Examples

Log.Error(exception, "An error has occurred when querying data objects.");
Log.Info("Found an Employee {Employee} in Department {Department}", employee, department);

Remarks

We use Serilog. Please look here for logging best practices.

Fields

CONTEXT

public const string CONTEXT = "Context"

Field Value

string

CORRELATION_ID

public const string CORRELATION_ID = "CorrelationId"

Field Value

string

REQUEST_ID

public const string REQUEST_ID = "RequestId"

Field Value

string

Properties

Context

public static string Context { get; }

Property Value

string

CorrelationId

public static string CorrelationId { get; }

Property Value

string

DisableLogging

public static bool DisableLogging { get; }

Property Value

bool

RequestId

public static string RequestId { get; }

Property Value

string

Methods

BeginContext(string)

public static Log.LoggingContext BeginContext(string context)

Parameters

context string

Returns

Log.LoggingContext

Debug(string)

Write a log event with the Debug level.

public static void Debug(string message)

Parameters

message string

The log message.

Debug(string, params object[])

Write a log event with the Debug level.

public static void Debug(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Debug(Exception, string, params object[])

Write a log event with the Debug level and associated exception.

public static void Debug(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Disable()

public static void Disable()

Error(string)

Write a log event with the Error level.

public static void Error(string message)

Parameters

message string

The log message.

Error(string, params object[])

Write a log event with the Error level.

public static void Error(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Error(Exception, string, params object[])

Write a log event with the Error level and associated exception.

public static void Error(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Fatal(string)

Write a log event with the Fatal level.

public static void Fatal(string message)

Parameters

message string

The log message.

Fatal(string, params object[])

Write a log event with the Fatal level.

public static void Fatal(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Fatal(Exception, string, params object[])

Write a log event with the Fatal level and associated exception.

public static void Fatal(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

For<T>()

public static ILogger For<T>()

Returns

ILogger

Type Parameters

T

For(Type)

public static ILogger For(Type type)

Parameters

type Type

Returns

ILogger

Info(string, params object[])

Write a log event with the Information level.

public static void Info(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Info(Exception, string, params object[])

Write a log event with the Information level and associated exception.

public static void Info(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Info(string)

Write a log event with the Information level.

public static void Info(string message)

Parameters

message string

The log message.

Restore(bool)

public static void Restore(bool logState)

Parameters

logState bool

SetSystemLogWriteProtector(ISystemLogWriteProtector)

public static void SetSystemLogWriteProtector(ISystemLogWriteProtector systemLogWriteProtector)

Parameters

systemLogWriteProtector ISystemLogWriteProtector

Use(ILogger, string)

public static void Use(ILogger logger, string appName = "")

Parameters

logger ILogger

appName string

Verbose(string)

Write a log event with the Verbose level.

public static void Verbose(string message)

Parameters

message string

The log message.

Verbose(string, params object[])

Write a log event with the Verbose level.

public static void Verbose(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Verbose(Exception, string, params object[])

Write a log event with the Verbose level and associated exception.

public static void Verbose(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Warning(Exception, string, params object[])

Write a log event with the Warning level and associated exception.

public static void Warning(Exception exception, string message, params object[] propertyValues)

Parameters

exception Exception

The associated exception.

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Warning(string, params object[])

Write a log event with the Warning level.

public static void Warning(string message, params object[] propertyValues)

Parameters

message string

The log message.

propertyValues object[]

Objects positionally formatted into the message.

Warning(string)

Write a log event with the Warning level.

public static void Warning(string message)

Parameters

message string

The log message.