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
Methods
FormatParameters(IDbCommand)
protected static string FormatParameters(IDbCommand command)
Parameters
command
IDbCommand
Returns
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
ILoggerelapsed
doublecommandType
CommandTypecommandTimeout
intcommandText
stringparameterText
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
IDbCommandThe command to log.
duration
TimeSpanThe execution duration.
exception
ExceptionThe exception thrown when executing the command.
state
objectThe 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
ILoggerelapsed
doublecommandType
CommandTypecommandTimeout
intcommandText
stringparameterText
stringexception
Exception