Table of Contents

Interface ILog

Namespace
Common.Log
Assembly
Lykke.Common.dll

Log abstraction. Do not inject this interface directly into your class, instead of this, inject ILoggerFactory and obtain log using one of CreateXXX methods.

public interface ILog
Extension Methods

Methods

BeginScope(string)

Begins logging scope. Could be used by some logger implementations

All entries, that will be logged inside scope, will contain as well.

Scopes could be nested

IDisposable BeginScope(string scopeMessage)

Parameters

scopeMessage string

Scope message

Returns

IDisposable

IsEnabled(LogLevel)

Checks if given logLevel enabled

bool IsEnabled(LogLevel logLevel)

Parameters

logLevel LogLevel

Log severity level to check

Returns

bool

Log<TState>(LogLevel, EventId, TState, Exception, Func<TState, Exception, string>)

Writes an entry to the log. This is low level method and usually should not be used directly in the app. It's inteded to be used only in some special infrastructural cases and for future extensions. App developer usually should use one of: Trace(ILog, string, object, Exception, DateTime?, string, string, int), Debug(ILog, string, object, Exception, DateTime?, string, string, int), Info(ILog, string, object, Exception, DateTime?, string, string, int), Warning(ILog, string, Exception, object, DateTime?, string, string, int), Error(ILog, Exception, string, object, DateTime?, string, string, int), Critical(ILog, Exception, string, object, DateTime?, string, string, int) extension methods or they overloads

void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) where TState : LogEntryParameters

Parameters

logLevel LogLevel

Log severity level

eventId EventId

Event ID

state TState

Entry state

exception Exception

Exception

formatter Func<TState, Exception, string>

Message formatter. Could be used by some of the logger implementations

Type Parameters

TState

Entry state type

WriteErrorAsync(string, string, Exception, DateTime?)

Writes error message

[Obsolete("Use overloads of the new extension methods: Error()")]
Task WriteErrorAsync(string process, string context, Exception exception, DateTime? dateTime = null)

Parameters

process string
context string
exception Exception
dateTime DateTime?

Returns

Task

Remarks

Write a error when exception was thrown, but app can still run

WriteErrorAsync(string, string, string, Exception, DateTime?)

Writes error message

[Obsolete("Use overloads of the new extension methods: Error()")]
Task WriteErrorAsync(string component, string process, string context, Exception exception, DateTime? dateTime = null)

Parameters

component string
process string
context string
exception Exception
dateTime DateTime?

Returns

Task

Remarks

Write a error when exception was thrown, but app can still run

WriteFatalErrorAsync(string, string, Exception, DateTime?)

Writes fatal error message

[Obsolete("Use overloads of the new extension methods: Critical()")]
Task WriteFatalErrorAsync(string process, string context, Exception exception, DateTime? dateTime = null)

Parameters

process string
context string
exception Exception
dateTime DateTime?

Returns

Task

Remarks

Write a fatal error when exception was thrown and app can't still run anymore

WriteFatalErrorAsync(string, string, string, Exception, DateTime?)

Writes fatal error message

[Obsolete("Use overloads of the new extension methods: Error()")]
Task WriteFatalErrorAsync(string component, string process, string context, Exception exception, DateTime? dateTime = null)

Parameters

component string
process string
context string
exception Exception
dateTime DateTime?

Returns

Task

Remarks

Write a fatal error when exception was thrown and app can't still run anymore

WriteInfoAsync(string, string, string, DateTime?)

Writes info log message

[Obsolete("Use overloads of the new extension methods: Info()")]
Task WriteInfoAsync(string process, string context, string info, DateTime? dateTime = null)

Parameters

process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write an info message about whatever you need to to simplify debugging and maintenance

WriteInfoAsync(string, string, string, string, DateTime?)

Writes info log message

[Obsolete("Use overloads of the new extension methods: Info()")]
Task WriteInfoAsync(string component, string process, string context, string info, DateTime? dateTime = null)

Parameters

component string
process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write an info message about whatever you need to to simplify debugging and maintenance

WriteMonitorAsync(string, string, string, DateTime?)

Writes monitoring log message

[Obsolete]
Task WriteMonitorAsync(string process, string context, string info, DateTime? dateTime = null)

Parameters

process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write a monitoring message about app lifecycle events or health events (start, stop, etc.)

WriteMonitorAsync(string, string, string, string, DateTime?)

Writes monitoring log message

[Obsolete]
Task WriteMonitorAsync(string component, string process, string context, string info, DateTime? dateTime = null)

Parameters

component string
process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write a monitoring message about app lifecycle events or health events (start, stop, etc.)

WriteWarningAsync(string, string, string, Exception, DateTime?)

Writes warning message with exception

[Obsolete("Use overloads of the new extension methods: Warning()")]
Task WriteWarningAsync(string process, string context, string info, Exception ex, DateTime? dateTime = null)

Parameters

process string
context string
info string
ex Exception
dateTime DateTime?

Returns

Task

Remarks

Write a warning with exception when you catch an exception but it is not the error for you, and app can still run normally

WriteWarningAsync(string, string, string, DateTime?)

Writes warning message

[Obsolete("Use overloads of the new extension methods: Warning()")]
Task WriteWarningAsync(string process, string context, string info, DateTime? dateTime = null)

Parameters

process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write a warning when something went wrong without any exceptions, and app can still run normally

WriteWarningAsync(string, string, string, string, Exception, DateTime?)

Writes warning message with exception

[Obsolete("Use overloads of the new extension methods: Warning()")]
Task WriteWarningAsync(string component, string process, string context, string info, Exception ex, DateTime? dateTime = null)

Parameters

component string
process string
context string
info string
ex Exception
dateTime DateTime?

Returns

Task

Remarks

Write a warning with exception when you catch an exception but it is not the error for you, and app can still run normally

WriteWarningAsync(string, string, string, string, DateTime?)

Writes warning message

[Obsolete("Use overloads of the new extension methods: Warning()")]
Task WriteWarningAsync(string component, string process, string context, string info, DateTime? dateTime = null)

Parameters

component string
process string
context string
info string
dateTime DateTime?

Returns

Task

Remarks

Write a warning when something went wrong without any exceptions, and app can still run normally