Table of Contents

Class DataQueryLogger

Namespace
FluentCommand
Assembly
FluentCommand.dll

A class for logging queries

public class DataQueryLogger : IDataQueryLogger
Inheritance
DataQueryLogger
Implements
Inherited Members

Constructors

DataQueryLogger(ILogger<DataQueryLogger>)

Initializes a new instance of the DataQueryLogger class.

public DataQueryLogger(ILogger<DataQueryLogger> logger)

Parameters

logger ILogger<DataQueryLogger>

The logger.

Properties

Logger

protected ILogger Logger { get; }

Property Value

ILogger

Methods

FormatParameters(IDbCommand)

protected static string FormatParameters(IDbCommand command)

Parameters

command IDbCommand

Returns

string

LogCommand(ILogger, double, CommandType, int, string, string)

[LoggerMessage(0, LogLevel.Debug, "Executed DbCommand ({Elapsed} ms) [CommandType='{CommandType}', CommandTimeout='{CommandTimeout}']\r\n{CommandText}\r\n{ParameterText}")]
protected static void LogCommand(ILogger logger, double elapsed, CommandType commandType, int commandTimeout, string commandText, string parameterText)

Parameters

logger ILogger
elapsed double
commandType CommandType
commandTimeout int
commandText string
parameterText string

LogCommand(IDbCommand, TimeSpan, Exception, object)

Log the current specified command

public virtual void LogCommand(IDbCommand command, TimeSpan duration, Exception exception = null, object state = null)

Parameters

command IDbCommand

The command to log.

duration TimeSpan

The execution duration.

exception Exception

The exception thrown when executing the command.

state object

The state used to control logging.

Exceptions

ArgumentNullException

command

LogError(ILogger, double, CommandType, int, string, string, Exception)

[LoggerMessage(1, LogLevel.Error, "Error Executing DbCommand ({Elapsed} ms) [CommandType='{CommandType}', CommandTimeout='{CommandTimeout}']\r\n{CommandText}\r\n{ParameterText}")]
protected static void LogError(ILogger logger, double elapsed, CommandType commandType, int commandTimeout, string commandText, string parameterText, Exception exception)

Parameters

logger ILogger
elapsed double
commandType CommandType
commandTimeout int
commandText string
parameterText string
exception Exception

See Also