InMemoryLogEntry Class
Represents a log entry captured by an in-memory logger.
public sealed class InMemoryLogEntryExample
var logger = InMemoryLogger.CreateLogger("sample");
logger.LogInformation("User {UserId} logged in", 123);
var log = logger.Logs.Informations.Single();
Assert.Equal("User 123 logged in", log.Message);
Assert.True(log.TryGetParameterValue("UserId", out var userId));
Assert.Equal(123, userId);Properties
| Name | Description |
|---|---|
| Category | Gets the logger category name. |
| CreatedAt | Gets the timestamp when the log entry was created. |
| EventId | Gets the event identifier. |
| Exception | Gets the exception associated with the log entry. |
| LogLevel | Gets the log level. |
| Message | Gets the formatted log message. |
| Scopes | Gets the list of scopes active when the log entry was created. |
| State | Gets the state object associated with the log entry. |
Category
InMemoryLogEntry.csCreatedAt
InMemoryLogEntry.csGets the timestamp when the log entry was created.
public DateTimeOffset CreatedAt { get; }Property value
EventId
InMemoryLogEntry.csException
InMemoryLogEntry.csLogLevel
InMemoryLogEntry.csMessage
InMemoryLogEntry.csScopes
InMemoryLogEntry.csGets the list of scopes active when the log entry was created.
public IReadOnlyList<object?> Scopes { get; }Property value
State
InMemoryLogEntry.csMethods
| Name | Description |
|---|---|
| GetAllParameterValues(string) | Gets all parameter values with the specified name from the state and scopes. |
| ToString() | |
| TryGetParameterValue(string, object?) | Tries to retrieve the first parameter value with the specified name from the state or scopes. |
GetAllParameterValues(string)
InMemoryLogEntry.csGets all parameter values with the specified name from the state and scopes.
public IEnumerable<object?> GetAllParameterValues(string name)Parameters
namestring- The parameter name to search for.
Returns
IEnumerable<object?> An enumerable of all matching parameter values.
ToString()
InMemoryLogEntry.csTryGetParameterValue(string, object?)
InMemoryLogEntry.csTries to retrieve the first parameter value with the specified name from the state or scopes.