Interface IRelationalConnectionDiagnosticsLogger
- 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 IRelationalConnectionDiagnosticsLogger : IDiagnosticsLogger<DbLoggerCategory.Database.Connection>, 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
ConnectionClosed(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionClosed event.
void ConnectionClosed(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time before the connection was closed.
ConnectionClosedAsync(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionClosed event.
Task ConnectionClosedAsync(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time before the connection was closed.
Returns
ConnectionClosing(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionClosing event.
InterceptionResult ConnectionClosing(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- InterceptionResult
The result of execution, which may have been modified by an interceptor.
ConnectionClosingAsync(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionClosing event.
ValueTask<InterceptionResult> ConnectionClosingAsync(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
ConnectionCreated(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionCreated event.
DbConnection ConnectionCreated(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time it took to create the connection.
Returns
ConnectionCreating(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionCreating event.
InterceptionResult<DbConnection> ConnectionCreating(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- InterceptionResult<DbConnection>
The result of execution, which may have been modified by an interceptor.
ConnectionDisposed(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionDisposed event.
void ConnectionDisposed(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time it took to dispose the connection.
ConnectionDisposedAsync(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionDisposed event.
Task ConnectionDisposedAsync(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time it took to dispose the connection.
Returns
ConnectionDisposing(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionDisposing event.
InterceptionResult ConnectionDisposing(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- InterceptionResult
The result of execution, which may have been modified by an interceptor.
ConnectionDisposingAsync(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionDisposing event.
ValueTask<InterceptionResult> ConnectionDisposingAsync(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
ConnectionError(IRelationalConnection, Exception, DateTimeOffset, TimeSpan, bool)
Logs for the ConnectionError event.
void ConnectionError(IRelationalConnection connection, Exception exception, DateTimeOffset startTime, TimeSpan duration, bool logErrorAsDebug)
Parameters
connection
IRelationalConnectionThe connection.
exception
ExceptionThe exception representing the error.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe elapsed time before the operation failed.
logErrorAsDebug
boolA flag indicating the exception is being handled and so it should be logged at Debug level.
ConnectionErrorAsync(IRelationalConnection, Exception, DateTimeOffset, TimeSpan, bool, CancellationToken)
Logs for the ConnectionError event.
Task ConnectionErrorAsync(IRelationalConnection connection, Exception exception, DateTimeOffset startTime, TimeSpan duration, bool logErrorAsDebug, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
exception
ExceptionThe exception representing the error.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe elapsed time before the operation failed.
logErrorAsDebug
boolA flag indicating the exception is being handled and so it should be logged at Debug level.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
ConnectionOpened(IRelationalConnection, DateTimeOffset, TimeSpan)
Logs for the ConnectionOpened event.
void ConnectionOpened(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time before the connection was opened.
ConnectionOpenedAsync(IRelationalConnection, DateTimeOffset, TimeSpan, CancellationToken)
Logs for the ConnectionOpened event.
Task ConnectionOpenedAsync(IRelationalConnection connection, DateTimeOffset startTime, TimeSpan duration, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
duration
TimeSpanThe amount of time before the connection was opened.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
ConnectionOpening(IRelationalConnection, DateTimeOffset)
Logs for the ConnectionOpening event.
InterceptionResult ConnectionOpening(IRelationalConnection connection, DateTimeOffset startTime)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
Returns
- InterceptionResult
The result of execution, which may have been modified by an interceptor.
ConnectionOpeningAsync(IRelationalConnection, DateTimeOffset, CancellationToken)
Logs for the ConnectionOpening event.
ValueTask<InterceptionResult> ConnectionOpeningAsync(IRelationalConnection connection, DateTimeOffset startTime, CancellationToken cancellationToken)
Parameters
connection
IRelationalConnectionThe connection.
startTime
DateTimeOffsetThe time that the operation was started.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
ShouldLogConnectionClose(DateTimeOffset)
Whether ConnectionClosing or ConnectionClosed need to be logged.
bool ShouldLogConnectionClose(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogConnectionCreate(DateTimeOffset)
Whether ConnectionCreating or ConnectionCreated need to be logged.
bool ShouldLogConnectionCreate(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogConnectionDispose(DateTimeOffset)
Whether ConnectionDisposing or ConnectionDisposed need to be logged.
bool ShouldLogConnectionDispose(DateTimeOffset now)
Parameters
now
DateTimeOffset
Returns
ShouldLogConnectionOpen(DateTimeOffset)
Whether ConnectionOpening or ConnectionOpened need to be logged.
bool ShouldLogConnectionOpen(DateTimeOffset now)
Parameters
now
DateTimeOffset