# IDurableLog&lt;T&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/)

## Append(T) {#append-t-6e29e74e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/append-t-6e29e74e/)

```csharp
public abstract long Append(T item)
```

Appends an entry to the log.

### Parameters

- `item` (`T`): The entry.

### Returns

The entry's sequence number.

### Exceptions

- `System.InvalidOperationException`: The log is sealed.

## BeginDraft {#begindraft-2fc02ba2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/begindraft-2fc02ba2/)

```csharp
public abstract IDurableLogDraft<T> BeginDraft()
```

Opens a draft which streams volatile items to readers which include drafts.

### Returns

The open draft. Dispose it to abandon the draft unless it was closed.

### Exceptions

- `System.InvalidOperationException`: The log is sealed.

## Clear {#clear-d850006a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/clear-d850006a/)

```csharp
public abstract void Clear()
```

Discards every entry, such as to replace the discarded entries with a compacted summary.

### Exceptions

- `System.InvalidOperationException`: The log is sealed.

## ReadAsync(long, long, bool, LogDraftId?, CancellationToken) {#readasync-long-long-bool-orleans-durable-journaling-logdraftid-nullable-system-t-553513af}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/readasync-long-long-bool-orleans-durable-journaling-logdraftid-nullable-system-t-553513af/)

```csharp
public abstract IAsyncEnumerable<LogEvent<T>> ReadAsync(long fromSequence = 0, long epoch = 0, bool includeDrafts = false, LogDraftId? resumeDraftId = null, CancellationToken cancellationToken = default(CancellationToken))
```

Reads the log's committed entries from a position, then waits for new entries.

### Parameters

- `fromSequence` (`long`): The sequence number of the first entry to read.
- `epoch` (`long`): The epoch of the history which `fromSequence` belongs to, from `Orleans.Durable.Journaling.LogEvent-1.Epoch`, or zero to read the current history. When the epoch differs from `Orleans.Durable.Journaling.IDurableLog-1.Epoch`, the stream begins with [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/).
- `includeDrafts` (`bool`): Whether the stream also delivers draft events: [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/), [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/), and [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/).
- `resumeDraftId` (`LogDraftId?`): The draft a reconnecting reader which includes drafts was viewing. When the draft is still open, the stream repeats its items from the beginning. When it committed, the stream reports [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/) with the entries which replaced it, in any activation, while the log retains the first of those entries. When it closed in this activation without committing, the stream reports [LogEventKind](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logeventkind/) with its [LogDraftAbandonReason](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logdraftabandonreason/). Otherwise, the stream reports [LogDraftAbandonReason](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logdraftabandonreason/) for a draft opened by another activation and [LogDraftAbandonReason](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.logdraftabandonreason/) for a draft of this activation.
- `cancellationToken` (`CancellationToken`): The token which ends the read.

### Returns

A stream of committed entries in sequence order. Each entry is delivered once the journal write which contains it is acknowledged. When `includeDrafts` is `true`, the stream also delivers draft items as they are written, and reports a committed draft once the entries which replaced it are durable.

### Exceptions

- `System.ArgumentOutOfRangeException`: `fromSequence` or `epoch` is negative.
- `System.InvalidOperationException`: Enumeration began before the owning manager recovered its state, or after a failed journal operation stopped it.

## Seal {#seal-8305be66}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/seal-8305be66/)

```csharp
public abstract void Seal()
```

Durably ends the log.

## TrimBefore(long) {#trimbefore-long-9fab0707}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/trimbefore-long-9fab0707/)

```csharp
public abstract void TrimBefore(long sequence)
```

Discards entries with sequence numbers lower than `sequence`.

### Parameters

- `sequence` (`long`): The sequence number of the first entry to retain.

### Exceptions

- `System.ArgumentOutOfRangeException`: `sequence` is negative or greater than `Orleans.Durable.Journaling.IDurableLog-1.NextSequence`.

## TryGet(long, T) {#tryget-long-out-t-fb50e718}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.journaling.idurablelog-1/methods/tryget-long-out-t-fb50e718/)

```csharp
public abstract bool TryGet(long sequence, out T item)
```

Attempts to get the retained entry with the specified sequence number.

### Parameters

- `sequence` (`long`): The entry's sequence number.
- `item` (`T`): The entry, if retained.

### Returns

`true` if the log retains an entry with `sequence`; otherwise, `false`.
