# PrimaryBasedLogViewAdaptor&lt;TLogView, TLogEntry, TSubmissionEntry&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/)

## ClearLogAsync(CancellationToken) {#clearlogasync-system-threading-cancellationtoken-57cf1480}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/clearlogasync-system-threading-cancellationtoken-57cf1480/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L99-L113)

```csharp
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, ClearLogAsync(CancellationToken cancellationToken)
```

Clear the log stream completely. Throws `System.NotSupportedException` if the log stream does not support clearing.

### Parameters

- `cancellationToken` (`CancellationToken`): A cancellation token to cancel the operation.

### Returns

A task that represents the asynchronous clear operation.

## ConfirmSubmittedEntries {#confirmsubmittedentries-32dd52f3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/confirmsubmittedentries-32dd52f3/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L785-L794)

```csharp
public Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, ConfirmSubmittedEntries()
```

Confirm all submitted entries. 

Waits until all previously submitted entries appear in the confirmed prefix of the log.

### Returns

A task that completes after all entries are confirmed.

## DisableStatsCollection {#disablestatscollection-17286960}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/disablestatscollection-17286960/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L526-L527)

```csharp
public void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, DisableStatsCollection()
```

Disable stats collection

## EnableStatsCollection {#enablestatscollection-c19ac120}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/enablestatscollection-c19ac120/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L500-L519)

```csharp
public virtual void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, EnableStatsCollection()
```

method is virtual so subclasses can add their own events

## GetStats {#getstats-9bed2289}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/getstats-9bed2289/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L535)

```csharp
public LogConsistencyStatistics PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, GetStats()
```

Get states

## OnProtocolMessageReceived(ILogConsistencyProtocolMessage) {#onprotocolmessagereceived-orleans-eventsourcing-ilogconsistencyprotocolmessage-359df78b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/onprotocolmessagereceived-orleans-eventsourcing-ilogconsistencyprotocolmessage-359df78b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L474-L492)

```csharp
public Task<ILogConsistencyProtocolMessage> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, OnProtocolMessageReceived(ILogConsistencyProtocolMessage payLoad)
```

Called from network

### Parameters

- `payLoad` (`ILogConsistencyProtocolMessage`)

## PostOnActivate {#postonactivate-9c257f17}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/postonactivate-9c257f17/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L211-L219)

```csharp
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PostOnActivate()
```

Called during activation, right after the user-defined [Grain](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/)..

## PostOnDeactivate {#postondeactivate-57591dfc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/postondeactivate-57591dfc/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L225-L234)

```csharp
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PostOnDeactivate()
```

Called during deactivation, right after the user-defined [Grain](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/).

## PreOnActivate {#preonactivate-2bbe6c88}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/preonactivate-2bbe6c88/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L198-L206)

```csharp
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PreOnActivate()
```

Called during activation, right before the user-defined [Grain](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/).

## RetrieveLogSegment(int, int) {#retrievelogsegment-int-int-22303705}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/retrievelogsegment-int-int-22303705/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L85)

```csharp
public virtual Task<IReadOnlyList<TLogEntry>> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, RetrieveLogSegment(int fromVersion, int length)
```

Attempt to retrieve a segment of the log, possibly from storage. Throws `System.NotSupportedException` if the log cannot be read, which depends on the providers used and how they are configured.

### Parameters

- `fromVersion` (`int`): the start position
- `length` (`int`): the end position

### Returns

a

## Submit(TLogEntry) {#submit-tlogentry-67a1f9b3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/submit-tlogentry-67a1f9b3/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L316-L326)

```csharp
public void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, Submit(TLogEntry logEntry)
```

Submit a single log entry to be appended to the global log, either at the current or at any later position.

### Parameters

- `logEntry` (`TLogEntry`)

## SubmitRange(IEnumerable&lt;TLogEntry&gt;) {#submitrange-system-collections-generic-ienumerable-tlogentry-e4dfc391}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/submitrange-system-collections-generic-ienumerable-tlogentry-e4dfc391/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L331-L344)

```csharp
public void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, SubmitRange(IEnumerable<TLogEntry> logEntries)
```

Submit a range of log entries to be appended atomically to the global log, either at the current or at any later position.

### Parameters

- `logEntries` (`IEnumerable<TLogEntry>`)

## Synchronize {#synchronize-3a1de632}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/synchronize-3a1de632/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L762-L771)

```csharp
public Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, Synchronize()
```

Get the latest log view and confirm all submitted entries. 

Waits until all previously submitted entries appear in the confirmed prefix of the log, and forces a refresh of the confirmed prefix.

### Returns

A task that completes after getting the latest version and confirming all entries.

## TryAppend(TLogEntry) {#tryappend-tlogentry-915fa657}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/tryappend-tlogentry-915fa657/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L349-L362)

```csharp
public Task<bool> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TryAppend(TLogEntry logEntry)
```

Try to append a single log entry at the current position of the log.

### Parameters

- `logEntry` (`TLogEntry`)

### Returns

true if the entry was appended successfully, or false if there was a concurrency conflict (i.e. some other entries were previously appended).

## TryAppendRange(IEnumerable&lt;TLogEntry&gt;) {#tryappendrange-system-collections-generic-ienumerable-tlogentry-7364441d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.eventsourcing/orleans.eventsourcing.common.primarybasedlogviewadaptor-3/methods/tryappendrange-system-collections-generic-ienumerable-tlogentry-7364441d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.EventSourcing/Common/PrimaryBasedLogViewAdaptor.cs#L368-L388)

```csharp
public Task<bool> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TryAppendRange(IEnumerable<TLogEntry> logEntries)
```

Try to append a range of log entries atomically at the current position of the log.

### Parameters

- `logEntries` (`IEnumerable<TLogEntry>`)

### Returns

true if the entries were appended successfully, or false if there was a concurrency conflict (i.e. some other entries were previously appended).
