# JournalingHostingExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/)

## AddJournalStorage(ISiloBuilder, string, Func&lt;IServiceProvider, TProvider&gt;) {#addjournalstorage-1-this-orleans-hosting-isilobuilder-string-system-func-system-9c2eb6c9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addjournalstorage-1-this-orleans-hosting-isilobuilder-string-system-func-system-9c2eb6c9/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L146-L217)

```csharp
public static ISiloBuilder AddJournalStorage<TProvider>(this ISiloBuilder builder, string name, Func<IServiceProvider, TProvider> factory)
```

Registers a named journal storage provider and its journaled state manager factory.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The provider name.
- `factory` (`Func<IServiceProvider, TProvider>`): The factory which creates the singleton provider.

### Returns

The silo builder.

### Exceptions

- `System.ArgumentNullException`: The builder or factory is null.
- `System.ArgumentException`: The provider name is empty or whitespace.
- `System.InvalidOperationException`: The name is already registered with another provider type.

## AddJournaling(ISiloBuilder) {#addjournaling-this-orleans-hosting-isilobuilder-67c897a9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addjournaling-this-orleans-hosting-isilobuilder-67c897a9/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L28-L56)

```csharp
public static ISiloBuilder AddJournaling(this ISiloBuilder builder)
```

Adds the services, durable state types, and journal formats required for journaling.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.

### Returns

The silo builder.

## AddStateMachine(IServiceCollection) {#addstatemachine-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-8a1004e0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addstatemachine-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-8a1004e0/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L77-L79)

```csharp
public static IServiceCollection AddStateMachine<TState, TImplementation>(this IServiceCollection services)
```

Registers a custom durable state contract and its state machine implementation.

### Parameters

- `services` (`IServiceCollection`): The service collection.

### Returns

The service collection.

## AddStateMachine(IServiceCollection, Func&lt;IServiceProvider, string, TImplementation&gt;) {#addstatemachine-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-74249058}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addstatemachine-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-74249058/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L101-L117)

```csharp
public static IServiceCollection AddStateMachine<TState, TImplementation>(this IServiceCollection services, Func<IServiceProvider, string, TImplementation> factory)
```

Registers a factory for a custom durable state contract.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `factory` (`Func<IServiceProvider, string, TImplementation>`): Creates a state component using its activation's service scope and stable state name.

### Returns

The service collection.

## AddVolatileJournalStorage(ISiloBuilder) {#addvolatilejournalstorage-this-orleans-hosting-isilobuilder-a8fbc0aa}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addvolatilejournalstorage-this-orleans-hosting-isilobuilder-a8fbc0aa/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L225)

```csharp
public static ISiloBuilder AddVolatileJournalStorage(this ISiloBuilder builder)
```

Registers volatile in-memory journal storage as the default provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.

### Returns

The silo builder.

## AddVolatileJournalStorage(ISiloBuilder, string) {#addvolatilejournalstorage-this-orleans-hosting-isilobuilder-string-3659f6d0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalinghostingextensions/methods/addvolatilejournalstorage-this-orleans-hosting-isilobuilder-string-3659f6d0/)

[Source](https://github.com/dotnet/orleans/blob/8efd4352592e66dffd235c823bfb83ecb3945320/src/Orleans.Journaling/JournalingHostingExtensions.cs#L234)

```csharp
public static ISiloBuilder AddVolatileJournalStorage(this ISiloBuilder builder, string name)
```

Registers an independent named volatile in-memory journal storage provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The provider name.

### Returns

The silo builder.
