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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethodDbCommandMethodRepresents the method that will be called to execute the command.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe amount of time that passed until the exception was raised.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethodDbCommandMethodRepresents the method that will be called to execute the command.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe amount of time that passed until the exception was raised.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
commandMethodDbCommandMethodThe type of method that will be called on this command.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command creation.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandMethodDbCommandMethodThe type of method that will be called on this command.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethodDbCommandMethodRepresents the method that will be called to execute the command.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
exceptionExceptionThe exception that caused this failure.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe amount of time that passed until the exception was raised.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
executeMethodDbCommandMethodRepresents the method that will be called to execute the command.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
exceptionExceptionThe exception that caused this failure.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe amount of time that passed until the exception was raised.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
commandMethodDbCommandMethodThe type of method that will be called on this command.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command creation.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultintThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultintThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultDbDataReaderThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultDbDataReaderThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultobjectThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
methodResultobjectThe return value from the underlying method execution.
startTimeDateTimeOffsetThe time that execution began.
durationTimeSpanThe duration of the command execution, not including consuming results.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
contextDbContextThe Microsoft.EntityFrameworkCore.DbContext currently being used, to null if not known.
commandIdGuidThe correlation ID associated with the given DbCommand.
connectionIdGuidThe correlation ID associated with the DbConnection being used.
startTimeDateTimeOffsetThe time that execution began.
commandSourceCommandSourceSource of the command.
cancellationTokenCancellationTokenA 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
dataReaderDbDataReaderThe data reader.
commandIdGuidThe correlation ID associated with the given DbCommand.
recordsAffectedintThe number of records in the database that were affected.
readCountintThe number of records that were read.
startTimeDateTimeOffsetThe 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
dataReaderDbDataReaderThe data reader.
commandIdGuidThe correlation ID associated with the given DbCommand.
recordsAffectedintThe number of records in the database that were affected.
readCountintThe number of records that were read.
startTimeDateTimeOffsetThe 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
connectionIRelationalConnectionThe connection.
commandDbCommandThe database command object.
dataReaderDbDataReaderThe data reader.
commandIdGuidThe correlation ID associated with the given DbCommand.
recordsAffectedintThe number of records in the database that were affected.
readCountintThe number of records that were read.
startTimeDateTimeOffsetThe time that the operation was started.
durationTimeSpanThe 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
nowDateTimeOffset
Returns
ShouldLogCommandExecute(DateTimeOffset)
Whether CommandExecuting or CommandExecuted need to be logged.
bool ShouldLogCommandExecute(DateTimeOffset now)
Parameters
nowDateTimeOffset
Returns
ShouldLogDataReaderClose(DateTimeOffset)
Whether DataReaderClosing needs to be logged.
bool ShouldLogDataReaderClose(DateTimeOffset now)
Parameters
nowDateTimeOffset
Returns
ShouldLogDataReaderDispose(DateTimeOffset)
Whether DataReaderDisposing needs to be logged.
bool ShouldLogDataReaderDispose(DateTimeOffset now)
Parameters
nowDateTimeOffset