# Class MemoryProcessLogger OptimaJet.Workflow.Core.Logging.MemoryProcessLogger Provides an in-memory [IProcessLogProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/IProcessLogProvider/) that groups [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances by [ProcessLogEntry.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/). Namespace: [OptimaJet.Workflow.Core.Logging](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/) ```csharp public class MemoryProcessLogger : IProcessLogProvider ``` ## Type Hierarchy - MemoryProcessLogger Current type - Implemented interfaces - [IProcessLogProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/IProcessLogProvider/) ## Constructors `public MemoryProcessLogger(int logSize, int capacity)` Creates a logger with the specified capacities for stored [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances and processes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `logSize` | `Int32` | The value assigned to [MemoryProcessLogger.LogSize](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) and used as the capacity of each [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/). | | `capacity` | `Int32` | The value assigned to [MemoryProcessLogger.Capacity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) and checked by [MemoryProcessLogger.Write(ProcessLogEntry)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) before a [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) is stored. | ## Properties `public int LogSize { get; }` Gets the capacity assigned to each [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/) created by [MemoryProcessLogger.Write(ProcessLogEntry)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/). `public int Capacity { get; }` Gets the configured number of process-specific [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/) instances at which [MemoryProcessLogger.Write(ProcessLogEntry)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) begins ignoring [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances. `public ConcurrentDictionary> ProcessLogs { get; }` Gets the in-memory storage that maps each [ProcessLogEntry.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) value to a [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/). ## Methods `public void Write(ProcessLogEntry entry)` Writes `entry` to the provider. ### Parameters | Name | Type | Description | | --- | --- | --- | | `entry` | `ProcessLogEntry` | The [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) to write. | ### Remarks If [MemoryProcessLogger.ProcessLogs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) already contains at least [MemoryProcessLogger.Capacity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/) instances, `entry` is ignored, including when [MemoryProcessLogger.ProcessLogs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) already contains the instance selected by [ProcessLogEntry.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/). Otherwise, a new instance is created as needed. When the selected instance exceeds [MemoryProcessLogger.LogSize](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/), its oldest [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances are removed. `public Task> ReadAllAsync(Guid processId)` Retrieves all [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) value of the process whose [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | ### Returns | Type | Description | | --- | --- | | `Task` | The asynchronous operation that yields all [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances associated with the process. | `public Task> ReadLastAsync(Guid processId, DateTime time)` Retrieves [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances created after `time` for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) value of the process whose [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | | `time` | `DateTime` | The exclusive lower bound for [ProcessLogEntry.CreatedOn](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/). | ### Returns | Type | Description | | --- | --- | | `Task` | The asynchronous operation that yields the matching [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances. | `public Task> ReadLastAsync(Guid processId, int count)` Retrieves up to `count` of the most recent [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) value of the process whose [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | | `count` | `Int32` | The maximum number of [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | ### Returns | Type | Description | | --- | --- | | `Task` | The asynchronous operation that yields up to `count` of the most recent [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances, ordered from newest to oldest. | `public Task> ReadEarlyAsync(Guid processId, DateTime time, int count)` Retrieves up to `count` [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances created before `time` for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) value of the process whose [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | | `time` | `DateTime` | The exclusive upper bound for [ProcessLogEntry.CreatedOn](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/). | | `count` | `Int32` | The maximum number of [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances to retrieve. | ### Returns | Type | Description | | --- | --- | | `Task` | The asynchronous operation that yields up to `count` of the matching [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/) instances, ordered from newest to oldest. | ## Remarks [MemoryProcessLogger.Write(ProcessLogEntry)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) creates each [FixedSizedQueue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Utils/FixedSizedQueue-T/) with [MemoryProcessLogger.LogSize](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) as its capacity. When [MemoryProcessLogger.ProcessLogs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) contains at least [MemoryProcessLogger.Capacity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) such instances, [MemoryProcessLogger.Write(ProcessLogEntry)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) ignores the supplied [ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/). [Previous IProcessLogProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/IProcessLogProvider/) [Next ProcessLogEntry](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ProcessLogEntry/)