Interface IRelationalCommandDiagnosticsLogger
- Namespace
- Microsoft.EntityFrameworkCore.Diagnostics
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
An Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger<> with some extra functionality suited for high-performance logging.
public interface IRelationalCommandDiagnosticsLogger : IDiagnosticsLogger<DbLoggerCategory.Database.Command>, IDiagnosticsLogger
Remarks
The service lifetime is Scoped. This means that each Microsoft.EntityFrameworkCore.DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.
See Implementation of database providers and extensions for more information and examples.
Methods
CommandCanceled(IRelationalConnection, DbCommand, DbContext?, DbCommandMethod, Guid, Guid, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandCanceled event.
void CommandCanceled(IRelationalConnection connection, DbCommand command, DbContext? context, DbCommandMethod executeMethod, Guid commandId, Guid connectionId, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethod
DbCommandMethodRepresents the method that will be called to execute the command.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe amount of time that passed until the exception was raised.
commandSource
CommandSourceSource of the command.
CommandCanceledAsync(IRelationalConnection, DbCommand, DbContext?, DbCommandMethod, Guid, Guid, DateTimeOffset, TimeSpan, CommandSource, CancellationToken)
Logs for the CommandCanceled event.
Task CommandCanceledAsync(IRelationalConnection connection, DbCommand command, DbContext? context, DbCommandMethod executeMethod, Guid commandId, Guid connectionId, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethod
DbCommandMethodRepresents the method that will be called to execute the command.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe amount of time that passed until the exception was raised.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandCreated(IRelationalConnection, DbCommand, DbCommandMethod, DbContext?, Guid, Guid, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandCreated event.
DbCommand CommandCreated(IRelationalConnection connection, DbCommand command, DbCommandMethod commandMethod, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
commandMethod
DbCommandMethodThe type of method that will be called on this command.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command creation.
commandSource
CommandSourceSource of the command.
Returns
- DbCommand
An intercepted result.
CommandCreating(IRelationalConnection, DbCommandMethod, DbContext?, Guid, Guid, DateTimeOffset, CommandSource)
Logs for the CommandCreating event.
InterceptionResult<DbCommand> CommandCreating(IRelationalConnection connection, DbCommandMethod commandMethod, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
commandMethod
DbCommandMethodThe type of method that will be called on this command.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
Returns
- InterceptionResult<DbCommand>
An intercepted result.
CommandError(IRelationalConnection, DbCommand, DbContext?, DbCommandMethod, Guid, Guid, Exception, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandError event.
void CommandError(IRelationalConnection connection, DbCommand command, DbContext? context, DbCommandMethod executeMethod, Guid commandId, Guid connectionId, Exception exception, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethod
DbCommandMethodRepresents the method that will be called to execute the command.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
exception
ExceptionThe exception that caused this failure.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe amount of time that passed until the exception was raised.
commandSource
CommandSourceSource of the command.
CommandErrorAsync(IRelationalConnection, DbCommand, DbContext?, DbCommandMethod, Guid, Guid, Exception, DateTimeOffset, TimeSpan, CommandSource, CancellationToken)
Logs for the CommandError event.
Task CommandErrorAsync(IRelationalConnection connection, DbCommand command, DbContext? context, DbCommandMethod executeMethod, Guid commandId, Guid connectionId, Exception exception, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethod
DbCommandMethodRepresents the method that will be called to execute the command.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
exception
ExceptionThe exception that caused this failure.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe amount of time that passed until the exception was raised.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandInitialized(IRelationalConnection, DbCommand, DbCommandMethod, DbContext?, Guid, Guid, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandInitialized event.
DbCommand CommandInitialized(IRelationalConnection connection, DbCommand command, DbCommandMethod commandMethod, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
commandMethod
DbCommandMethodThe type of method that will be called on this command.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command creation.
commandSource
CommandSourceSource of the command.
Returns
- DbCommand
An intercepted result.
CommandNonQueryExecuted(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, int, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandExecuted event.
int CommandNonQueryExecuted(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, int methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
intThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
Returns
- int
The result of execution, which may have been modified by an interceptor.
CommandNonQueryExecutedAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, int, DateTimeOffset, TimeSpan, CommandSource, CancellationToken)
Logs for the CommandExecuted event.
ValueTask<int> CommandNonQueryExecutedAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, int methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
intThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandNonQueryExecuting(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource)
Logs for the CommandExecuting event.
InterceptionResult<int> CommandNonQueryExecuting(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
Returns
- InterceptionResult<int>
An intercepted result.
CommandNonQueryExecutingAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource, CancellationToken)
Logs for the CommandExecuting event.
ValueTask<InterceptionResult<int>> CommandNonQueryExecutingAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandReaderExecuted(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DbDataReader, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandExecuted event.
DbDataReader CommandReaderExecuted(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DbDataReader methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
DbDataReaderThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
Returns
- DbDataReader
The result of execution, which may have been modified by an interceptor.
CommandReaderExecutedAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DbDataReader, DateTimeOffset, TimeSpan, CommandSource, CancellationToken)
Logs for the CommandExecuted event.
ValueTask<DbDataReader> CommandReaderExecutedAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DbDataReader methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
DbDataReaderThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<DbDataReader>
The result of execution, which may have been modified by an interceptor.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandReaderExecuting(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource)
Logs for the CommandExecuting event.
InterceptionResult<DbDataReader> CommandReaderExecuting(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
Returns
- InterceptionResult<DbDataReader>
An intercepted result.
CommandReaderExecutingAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource, CancellationToken)
Logs for the CommandExecuting event.
ValueTask<InterceptionResult<DbDataReader>> CommandReaderExecutingAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<InterceptionResult<DbDataReader>>
An intercepted result.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandScalarExecuted(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, object?, DateTimeOffset, TimeSpan, CommandSource)
Logs for the CommandExecuted event.
object? CommandScalarExecuted(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, object? methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
objectThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
Returns
- object
The result of execution, which may have been modified by an interceptor.
CommandScalarExecutedAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, object?, DateTimeOffset, TimeSpan, CommandSource, CancellationToken)
Logs for the CommandExecuted event.
ValueTask<object?> CommandScalarExecutedAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, object? methodResult, DateTimeOffset startTime, TimeSpan duration, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
methodResult
objectThe return value from the underlying method execution.
startTime
DateTimeOffsetThe time that execution began.
duration
TimeSpanThe duration of the command execution, not including consuming results.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
CommandScalarExecuting(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource)
Logs for the CommandExecuting event.
InterceptionResult<object> CommandScalarExecuting(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
Returns
- InterceptionResult<object>
An intercepted result.
CommandScalarExecutingAsync(IRelationalConnection, DbCommand, DbContext?, Guid, Guid, DateTimeOffset, CommandSource, CancellationToken)
Logs for the CommandExecuting event.
ValueTask<InterceptionResult<object>> CommandScalarExecutingAsync(IRelationalConnection connection, DbCommand command, DbContext? context, Guid commandId, Guid connectionId, DateTimeOffset startTime, CommandSource commandSource, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
context
DbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandId
GuidThe correlation ID associated with the given DbCommand.
connectionId
GuidThe correlation ID associated with the DbConnection being used.
startTime
DateTimeOffsetThe time that execution began.
commandSource
CommandSourceSource of the command.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
DataReaderClosing(IRelationalConnection, DbCommand, DbDataReader, Guid, int, int, DateTimeOffset)
Logs for the DataReaderClosing event.
InterceptionResult DataReaderClosing(IRelationalConnection connection, DbCommand command, DbDataReader dataReader, Guid commandId, int recordsAffected, int readCount, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
dataReader
DbDataReaderThe data reader.
commandId
GuidThe correlation ID associated with the given DbCommand.
recordsAffected
intThe number of records in the database that were affected.
readCount
intThe number of records that were read.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- InterceptionResult
The result of execution, which may have been modified by an interceptor.
DataReaderClosingAsync(IRelationalConnection, DbCommand, DbDataReader, Guid, int, int, DateTimeOffset)
Logs for the DataReaderClosing event.
ValueTask<InterceptionResult> DataReaderClosingAsync(IRelationalConnection connection, DbCommand command, DbDataReader dataReader, Guid commandId, int recordsAffected, int readCount, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
dataReader
DbDataReaderThe data reader.
commandId
GuidThe correlation ID associated with the given DbCommand.
recordsAffected
intThe number of records in the database that were affected.
readCount
intThe number of records that were read.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- ValueTask<InterceptionResult>
The result of execution, which may have been modified by an interceptor.
DataReaderDisposing(IRelationalConnection, DbCommand, DbDataReader, Guid, int, int, DateTimeOffset, TimeSpan)
Logs for the DataReaderDisposing event.
InterceptionResult DataReaderDisposing(IRelationalConnection connection, DbCommand command, DbDataReader dataReader, Guid commandId, int recordsAffected, int readCount, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
command
DbCommandThe database command object.
dataReader
DbDataReaderThe data reader.
commandId
GuidThe correlation ID associated with the given DbCommand.
recordsAffected
intThe number of records in the database that were affected.
readCount
intThe number of records that were read.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe elapsed time from when the operation was started.
Returns
- InterceptionResult
The result of execution, which may have been modified by an interceptor.
ShouldLogCommandCreate(DateTimeOffset)
Whether CommandCreating or CommandCreated need to be logged.
bool ShouldLogCommandCreate(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogCommandExecute(DateTimeOffset)
Whether CommandExecuting or CommandExecuted need to be logged.
bool ShouldLogCommandExecute(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogDataReaderClose(DateTimeOffset)
Whether DataReaderClosing needs to be logged.
bool ShouldLogDataReaderClose(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogDataReaderDispose(DateTimeOffset)
Whether DataReaderDisposing needs to be logged.
bool ShouldLogDataReaderDispose(DateTimeOffset now)
Parameters
now
DateTimeOffset