---
title: Enable Logging and ultimately Monitoring with Non-Events using Serilog sinks with Nodinite as the central logging platform.
description: Serilog Logging and Monitoring. Learn how to enable end to end tracking including your .NET projects and solutions (like Azure functions) using one of the Nodinites Serilog sinks.
---

<a class="nodinite-release-notes" href="https://portal.nodinite.com/marketplace/15" data-url="https://portal.nodinite.com/marketplace/15"><i class="fal fa-fw fa-file-alt" aria-hidden="true"></i> Release Notes</a>

# <i class="fal fa-display" aria-hidden="true"></i> Logging using Serilog

Use one of the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> **Serilog sinks** with your full framework and .NET Core applications to **enable end-to-end tracking**. [Microsoft Azure functions][]<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup> built with .NET (usually CSharp) are typical. <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> sports payload Logging and removes the obstacle the Application insights logging imposes on message size.

<div class="mermaid">
graph LR
    A[.NET Application] --> | Log Event | SLS(Serilog)  
    F[fal:fa-function Azure Function] --> | Log Event | SLS  
    SLS --> | 1. | LAS[fal:fa-cloud-arrow-down Log API Sink]  
    LAS --> LA[fal:fa-cloud-arrow-down Nodinite Log API]
    SLS --> | 2. | SLEH[fa:fa-border-outer Event Hub Sink]  
    SLEH <--> PS[far:fa-truck-pickup Pickup Service]
    PS --> LA
    SLS --> | 3. | SLSB[fa:fa-list Service Bus Sink]  
    SLSB <--> PS
    SLS ---> | 5. | SLSF[far:fa-folder File Sink]  
    SLS ---> | 4. | SLBS[far:fa-container-storage Azure Blob Storage Sink]  
    SLSF <--> PS
    SLBS <--> PS
</div>

## <i class="fal fa-rocket" aria-hidden="true"></i> Why Choose Nodinite Logging Over Application Insights & Competing Solutions?  

In today’s fast-paced business environments, logging and monitoring are not just about collecting data—they're about **gaining actionable insights** without losing valuable context. While tools like **Application Insights** and other logging platforms require **predefined logic** to capture key values (such as order numbers or correlation IDs), **Nodinite Logging takes a different approach—one that eliminates guesswork, prevents data loss, and enhances long-term flexibility.**  

Nodinite integrates seamlessly with **Serilog**, offering specialized sinks for **both on-premise and cloud-based solutions**. Unlike other logging solutions, Nodinite can **log any payload size**, whereas Application Insights and many competitors impose strict limitations.  

## <i class="fal fa-code-compare" aria-hidden="true"></i> Nodinite Logging vs. Application Insights & Other Competitors  

### 1. Full Payload Logging—No Predefined Logic Needed

* With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you **don’t need to code up-front logic** to extract key values like correlation IDs, order numbers, or transaction details.  
* All message payloads and context values are logged in **full**, ensuring you always have **complete visibility** into your data.  
* **With Application Insights and other tools, if you forget to log a value, it’s lost forever. With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you can extract and index new fields at any time!**  

**🔑 Key Advantage:** No need for developers to anticipate every possible logging requirement—just **log everything and extract later** when the need arises.  

### 2. Flexible Search & Reindexing – No More Data Loss

* In most competing solutions, if you realize you need a **new search field**, it’s too late—the data has already been logged **without** that key information.  
* With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you can **create new search fields anytime** and **reindex old data** without losing any historical context.  
* If a field extraction was incorrect? **Just fix the expression and reindex—no lost data!**  

**🔑 Key Advantage:** No risk of data loss due to changing business needs or human error in defining log fields.  

### 3. Serilog-Based Logging for On-Prem & Cloud  

* <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> provides dedicated **Serilog sinks** for both **on-premise** and **cloud** environments, offering seamless integration with your existing logging infrastructure.  
* Works effortlessly with **.NET applications, containerized solutions, and cloud-native services**.  

**🔑 Key Advantage:** Native Serilog integration means **no need to change your logging framework**—just plug in <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> and start logging smarter.  

### 4. No Payload Size Limitations

* **Application Insights and many competitors** impose strict **size limits** on logged data, often **truncating valuable information** when payloads exceed the allowed size.  
* With **Nodinite, there are no payload size restrictions**—log **full messages, large transactions, and complex payloads** without worrying about data loss.  

**🔑 Key Advantage:** Capture **complete** logs, no matter how large the payload.  

### 5. Granular, Message-Type Level Retention

* Competing solutions often limit retention based on **fixed days or data volume quotas**, forcing businesses to choose between **losing valuable logs or paying excessive storage fees**.  
* **<span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> allows you to define retention per message type**, so **high-value business transactions** (e.g., financial transactions, critical orders) can be kept **longer**, while less important logs are purged earlier.  

**🔑 Key Advantage:** Optimize retention based on business value, not arbitrary time limits or storage constraints.  

## <i class="fal fa-fire" aria-hidden="true"></i> The Bottom Line: Why Nodinite Wins

✅ **Small effort upfront coding needed**—log everything and extract key values later.  
✅ **No data loss**—reindex old data anytime, even if requirements change.  
✅ **Native Serilog integration**—works with existing logging frameworks.  
✅ **No payload size limits**—log full messages without truncation.  
✅ **Granular retention control**—keep critical logs longer without excessive costs.  

💡**With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you never have to say "I wish we had logged that." Everything is available when you need it.**  

___

You can choose to use any of the available <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sinks, which are easily accessible on [NuGet](https://www.nuget.org)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>:  

|#|Sink|Authentication|Reliable Messaging|Message Size|Latest version|  
|:---:|---|:---:|:---:|---|---|  
|1.|<i class="fal fa-cloud-arrow-down" aria-hidden="true"></i> [Log API][Serilog - LogAPI]|Integrated [Windows Authentication][]|❌ No|>=0B|[![NuGet Version](https://img.shields.io/nuget/v/Nodinite.Serilog.ApiSink.svg?style=flat)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>](https://www.nuget.org/packages/Nodinite.Serilog.ApiSink/)|  
|2.|[Azure Event Hub][Serilog - Event Hub]|Managed Identity<sup><span class="nodinite-new-badge">New 2.0.0</span></sup></br>Connection string|✅ Yes|<1024KB|[![NuGet Version](https://img.shields.io/nuget/v/Nodinite.Serilog.EventHubSink.svg?style=flat)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>](https://www.nuget.org/packages/Nodinite.Serilog.EventHubSink/)|  
|3.|[Azure Service Bus][Serilog - Service Bus]|Managed Identity<sup><span class="nodinite-new-badge">New 2.0.0</span></sup></br>Connection string|✅ Yes|<256KB|[![NuGet Version](https://img.shields.io/nuget/v/Nodinite.Serilog.ServiceBusSink.svg?style=flat)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>](https://www.nuget.org/packages/Nodinite.Serilog.ServiceBusSink/)|  
|4.|[Azure Blob Storage Container][Serilog - Blob Storage]<sup><span class="nodinite-new-badge">New 2.0.14</span></sup>|Managed Identity</br>Connection string|✅ Yes|>=0B|[NuGet](https://www.nuget.org/packages/Nodinite.Serilog.AzureBlobStorageSink/)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>![NuGet Version](https://img.shields.io/nuget/v/Nodinite.Serilog.AzureBlobStorageSink.svg?style=flat)</sup>|  
|5.|[File (SMB)][Serilog - File]|Integrated Windows Authentication|✅ Yes|>=0B|[NuGet](https://www.nuget.org/packages/Nodinite.Serilog.FileSink/)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>![NuGet Version](https://img.shields.io/nuget/v/Nodinite.Serilog.FileSink.svg?style=flat)</sup>|  

> <i class="fal fa-code" aria-hidden="true"></i> [Develop Azure Functions using Visual Studio](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>

## Log Event

The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sink produces a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JSON Log Event][] which then the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Pickup Log Events Service Logging Agent][] consumes.

The [JSON Log Event][] has three distinct parts:

1. [Event details](#details) (also named **Additional field values** within <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>)
2. [Payload](#payload) (Body, 0 or more)
3. [Context properties](#context-properties) (Key/Value)

<div class="mermaid">
graph TD
    subgraph "Log Event"
        subgraph "1. Details"
            roED[fal:fa-bolt Event Details </br>LogDateTime = 2018-05-03 13:37:00+02:00</br> EndPointName = https://api.nodinite.com/... </br> MessageType=Invoice </br>...]
        end
        subgraph "2. Payload"
            ro[fal:fa-envelope Message</br>Body=base64EncodedMessage]
        end
        subgraph "3. Context Properties"
            roKey[fal:fa-key Key Values </br>InvoiceNo = 123 </br>CorrelationId=456 </br>...]
        end
    end
</div>

<aside aria-label="Info" class="nodinite-note nodinite-note--info">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-square-info"></i> Info</p>
<div class="nodinite-note__content"><p>Please review the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> <a href="https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/overview/">Pickup Log Events Service Logging Agent</a> for additional information.</p></div>
</aside>

### 1. Details

The following **mandatory** fields must be set, either in configuration or with code (values are example data and should be replaced with your logic):

|Mandatory|Data Type|Field|Value|Comment|  
|:---:|:---:|---|---|---|  
|✅ Yes|```number```|LogAgentValueId|42|Who ([Log Agents][]) sent the data|  
|✅ Yes|```string```|EndPointName|"Nodinite.Serilog.ApiSink.Tests"|Name of [Endpoint][Endpoints] transport|  
|✅ Yes|```string```|EndPointUri|"https://sampleazurefunction1337.azurewebsites.net/api/HttpTrigger1"|[URI][] for [Endpoint][Endpoints] transport|  
|✅ Yes|```number```|[EndPointDirection][Endpoint Directions]|10 (Two-way receive)|Direction for [Endpoint][Endpoints] transport|  
|✅ Yes|```number```|[EndPointTypeId][EndpointTypes]|86 (HTTPS)|Type of [Endpoint][Endpoints] transport|  
|✅ Yes|```string```|OriginalMessageTypeName|"https://contoso.com/Customers/1.0#Batch"|[Message Type Name][Message Types]|  

<aside aria-label="Info" class="nodinite-note nodinite-note--info">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-square-info"></i> Info</p>
<div class="nodinite-note__content"><p>The specified values are merely example data.</p></div>
</aside>

Review the [JSON Log Event][] user guide for details about the **optional** fields.

### 2. Payload

To log message payloads (body), add your **raw content as-is** to the context property "`body`". The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sink automatically handles the base64 encoding behind the scenes when generating the [JSON Log Event][].

* <i class="fal fa-brackets-curly" aria-hidden="true"></i> **JSON payloads**: Add as plain JSON string - `{"orderId": 123, "amount": 99.95}`
* <i class="fal fa-code" aria-hidden="true"></i> **XML payloads**: Add as plain XML string - `<order><id>123</id></order>`
* <i class="fal fa-align-left" aria-hidden="true"></i> **Text content**: Add as plain text string - `Customer order received`

The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog framework ensures proper base64 encoding when producing the final [JSON Log Event][] for processing.

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p><strong>Only manually base64 encode</strong> if you're bypassing the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog components and directly producing <a href="https://docs.nodinite.com/core-services/log-event/features/json-log-event/">JSON Log Event</a> structures yourself.</p></div>
</aside>

### 3. Context Properties

The following **optional coded context properties** are mapped if present to the following <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> "additional field values":

|Context Key|Description|  
|---|---|  
|<i class="fal fa-file-lines" aria-hidden="true"></i> body|Raw message payload (JSON, XML, text) - automatically base64 encoded by the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sink|  
|<i class="fal fa-envelope" aria-hidden="true"></i> OriginalMessageTypeName|Name of [MessageType][Message Types], if not set, the default value is `https://contoso.com/Customers/1.0#Batch`|  
|<i class="fal fa-fingerprint" aria-hidden="true"></i> ApplicationInterchangeId|Please re-use if possible a scenario wide id, for example the `x-ms-client-tracking-id` in Azure|  

Review the [Context Options][] user guide for additional features overriding the default behaviour.

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p><strong>Critical: Always set OriginalMessageTypeName for searchable data</strong></p><p>When logging with Serilog to Nodinite:</p><ol>
<li><a href="https://docs.nodinite.com/repository-model/message-types/overview/">Message Types</a> identify message formats (PurchaseOrder, Invoice, OrderConfirmation, CustomerUpdate, etc.)</li>
<li><a href="https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/">Search Field Expressions</a> extract business data - Order Numbers, Customer IDs, Invoice amounts, Transaction codes, etc.</li>
<li><a href="https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/">Log Views</a> become searchable by business identifiers, not just timestamps or correlation IDs</li>
<li><a href="https://docs.nodinite.com/logging-and-monitoring/non-events/overview/">Non-Events Monitoring</a> can track volumes, detect missing messages, and alert on pattern anomalies</li>
<li><a href="https://docs.nodinite.com/repository-model/bpms/overview/">Business Process Modeling (BPM)</a> can correlate transactions end-to-end across Azure Functions, Logic Apps, API Management, and other systems</li>
</ol><p><strong>Without proper <a href="https://docs.nodinite.com/repository-model/message-types/overview/">Message Types</a> and <a href="https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/">Search Fields</a>, your Serilog events are stored but not searchable by business data.</strong> Always include OriginalMessageTypeName when logging. Learn more: <a href="https://docs.nodinite.com/core-services/log-event/overview/">Log Event Processing</a></p></div>
</aside>

#### Automatically assigned

The following properties are automatically assigned by the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sink:

|Field|Description|Example|  
|---|---|---|  
|<i class="fal fa-fingerprint" aria-hidden="true"></i> **ServiceInstanceActivityId**|A guid unique for **each** log event|ee2daba2-4807-4ad8-1337-620e2b9c0052|  
|<i class="fal fa-fingerprint" aria-hidden="true"></i> **LocalInterchangeId**|A unique re-used guid set on all logged events within one class instance|ff2daba2-4807-4ad8-1337-620e2b9c0053|  
|<i class="fal fa-calendar-day" aria-hidden="true"></i> **LogDateTime**|UTC|2020-05-17T13:37:42.001+01:00|  
|<i class="fal fa-align-left" aria-hidden="true"></i> **LogText**|The text to log|Hello World|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> [Log Status Code][Log Status Codes]|The user defined Log Status Code for the logged event|Review the 'Log Status Code translation table' on this page.|  

#### Log Status Code translation table

The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log Status Codes][] are translated as described in the table below from the following Serilog Log Levels:

|Serilog Log Level|Nodinite Log Status Code|Nodinite Log Status|Code example|  
|---|---|---|---|  
|Debug|0|None|log.Debug|  
|Info|0|None|log.Information|  
|Verbose|0|None|log.Verbose|  
|Error|-1|Error|log.Error|  
|Fatal|-2|Fatal|log.Fatal|  
|Warning|1|Warning|log.Warning|  

___

## Step-by-step guide

The example assumes you are adding the Logging to an **Azure function**. However, it should be pretty straightforward to use this example for other project types.

You must add code and perform operations as follows:

|#|Source|Description|  
|---|---|---|  
|[1.](#add-nuget-package-reference)|Add a NuGet reference to one of the Nodinite Sinks|You need to select one that suits your requirements|  
|[2.](#program.cs)|In the program startup, for example `Program.cs`, this is where you add the singleton in use for great performance and optionally loads essential configuration data|You can opt to load settings from a settings file, or add extra field info during the logging|  
|[3.](#perform-logging)|Where code with logging runs, for example in the `Run(...)` method|Perform the actual Logging where is is needed|  
|[4.](#cleanup)|Cleanup|Before exiting the entry point, you should invoke a call to  `Dispose` the singleton logger|  

### 1: Add NuGet Package Reference

From Visual Studio, add to your Solution a package reference to one of the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Serilog sinks.

![Nodinite Serilog Sinks][1]  
*NuGet package manager example, filtered by Nodinite packages.*  

### 2: Program.cs

In the startup of your project, you need to perform two main tasks:

1. **Add configuration**
2. **Initialize the Logger**

#### 1. Add configuration

You have two options, either add the fields in the code; or have them in the Settings.json.

1. **Add configuration by code**
2. **Add configuration from the Settings file**

##### Add configuration by code  

The following example adds the configuration with code.

``` csharp
var connectionString = "Endpoint=sb://yournamespace.servicebus.windows.net/;SharedAccessKeyName=Default;SharedAccessKey=%hidden%;EntityPath=apieh";
  var settings = new NodiniteLogEventSettings()
  { 
      LogAgentValueId = 503, 
      EndPointDirection = 0, 
      EndPointTypeId = 0, 
      EndPointUri = "Nodinite.Serilog.Sink.Tests.Serilog", 
      EndPointName = "Nodinite.Serilog.Sink.Tests", 
      OriginalMessageTypeName = "Serilog.LogEvent", 
      ProcessingUser = "NODINITE", 
      ProcessName = "Nodinite.Serilog.Sink.Tests", 
      ProcessingMachineName = "NODINITE-DEV", 
      ProcessingModuleName = "DOTNETCORE.TESTS", 
      ProcessingModuleType = "DOTNETCORE.TESTPROJECT"   
  };
```

##### Add configuration from the settings file

The following example adds the configuration using a settings file.  

``` csharp
var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();
```

Sample `appsettings.json` file
Below is an example for the `NodiniteEventHubSink`, change as required.

Replace <%`NodiniteSinkName`%> with any of the following (depending on which package you opted for):

* `AzureBlobStorageSink` - Managed Identity  
* `AzureBlobStorageSinkWithConnectionString`  
* `NodiniteApiSink`  
* `NodiniteFileSink`  
* `NodiniteServiceBusSink`  
* `NodiniteEventHubSink`  

``` json
{
  "Serilog": {
    "Using": [ "<placeholder>" ],
    "WriteTo": [
      {
        "Name": "NodiniteEventHubSink",
        "Args": {
          "ConnectionString": "*******************************",
          "Settings": {
            "LogAgentValueId": 503,
            "EndPointName": "Nodinite.Serilog.Sink.Tests",
            "EndPointUri": "Nodinite.Serilog.Sink.Tests.Serilog",
            "EndPointDirection": 0,
            "EndPointTypeId": 0,
            "OriginalMessageTypeName": "Serilog.LogEvent",
            "ProcessingUser": "NODINITE",
            "ProcessName": "Nodinite.Serilog.Sink.Tests",
            "ProcessingMachineName": "NODINITE-DEV",
            "ProcessingModuleName": "DOTNETCORE.TESTS",
            "ProcessingModuleType": "DOTNETCORE.TESTPROJECT",
            "ReplaceRules": {
              "Body": [ "InputMessage", "OutputMessage" ],
              "ApplicationInterchangeId": [ "EventID" ],
              "LogStatus": [ "StatusCode" ]
            }      

          }
        }
      }
    ]
  }
}
```

#### 2. Initialize the Logger

Now in the `Startup.cs` file it is time to create the actual singleton logger.

If you added the configuration by code, please use the following example:

``` csharp
var logger = new LoggerConfiguration()
    .WriteTo.NodiniteEventHubSink(connectionString, settings)
    .CreateLogger();

builder.Services.AddSingleton<ILogger, Serilog.Core.Logger>(sp => logger);
```

Otherwise, if you added the configuration from a settings file, please use the following example:  

``` csharp
        var logger = new LoggerConfiguration()
            .ReadFrom.Configuration(configuration)
            .CreateLogger();
   
        services.AddSingleton<ILogger, Logger>(sp => logger);

```

### 3: Perform Logging

In your code, you must add a call to perform the Logging. The example includes the **full** payload together with some **context** data (key-value).

You are supposed to extend this sample with additional fields according to your requirements. **Make sure to set a proper name for the [Message Type][Message Types] as this is crucial to <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> - without it, your business data won't be searchable!**

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p><strong>Always include OriginalMessageType</strong> - This field determines which <a href="https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/">Search Field Expressions</a> will extract business data from your logged messages. Without the correct Message Type, features like <a href="https://docs.nodinite.com/logging-and-monitoring/non-events/overview/">Non-Events Monitoring</a>, <a href="https://docs.nodinite.com/repository-model/bpms/overview/">Business Process Modeling (BPM)</a>, and business-data searches in <a href="https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/">Log Views</a> won't work properly.</p></div>
</aside>

 ``` csharp
private void Log(string correlationId, string payload)
{
    _logger.ForContext(new PropertyEnricher("ApplicationInterchangeId", $"{correlationId}"))
        .ForContext(new PropertyEnricher("Body", JsonConvert.SerializeObject(payload)))
        .ForContext(new PropertyEnricher("OriginalMessageType", "OrderMessage#1.0"))
        .ForContext(new PropertyEnricher("LogStatusCode", -1337))
        .ForContext("Body", "{\"id\":1}")
        .Information("Hello from Function");
} 
```

<sup><span class="nodinite-new-badge">New 2.0.18</span></sup>  
If you want to log multiple bodies (Attachments), instead of **Body**, you can use **Bodies** and send a list of strings like in the following example.

 ```csharp
.ForContext("Bodies", "[{\"id\":1},{\"id\":2}]")
```

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p>If you also pass a payload using the <strong>Body</strong> field, the <strong>Bodies</strong> are treated as attachments. Hence, the <code>OriginalMessageType</code> is applied on the <strong>Body</strong>. If you only pass <strong>Bodies</strong>, the <code>OriginalMessageType</code> is applied  on the 1st entry in the list.</p></div>
</aside>

<sup><span class="nodinite-new-badge">New 2.0.23</span></sup>
You can override the [LogStatus][Log Status Codes] regardless of the type of log (i.e. .Information, .Warning, ...).

### 4: Cleanup

Before exiting the thread/run/invocation/... please call the `Dispose` method on the Logger as we are utilizing a singleton pattern.

Put this code after the **last** Logging operation.

```csharp
((Logger)_logger).Dispose();
```

### Replace Rules

<sup><span class="nodinite-new-badge">New 2.0.35</span></sup> **ReplaceRules** can be used to map **Semantic Logging** to map data to the structure of a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JSON Log Event][].

You can visit the `appsettings.json` example in the [Settings Section (appsettings.json)][Serilog - Settings Section].  

___

## .NET Exceptions

<sup><span class="nodinite-new-badge">New 1.3.0</span></sup>

If you log an Exception, for example using the `LogError(` method, the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> sink adds it to the **Context**. The name of the Context key is **ExtendedProperties/1.0#Exception**.

From <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you can then use the [Formula][] plugin to create [Search Fields][] and extract whatever information you seek from the Exception.  

![Extract Message from Exception][2]  
*Example extracting the **Message** part of an exception.*  

```json
JsonPath('..Message', Context('ExtendedProperties/1.0#Exception'))
```

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>The Exception can include nested exceptions.</p></div>
</aside>

## <i class="fal fa-shield-check" aria-hidden="true"></i> What firewall settings are required for the Nodinite Serilog sinks?

The sinks run inside your application, so every connection is **outbound** from the Application Server; nothing calls into it, and there is no [Monitoring Service][] or Agent Server hop. The sink you choose decides the path: the [Log API][Serilog - LogAPI] sink posts directly to the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log API][]; the [Event Hub][Serilog - Event Hub], [Service Bus][Serilog - Service Bus], [Blob Storage][Serilog - Blob Storage], and [File][Serilog - File] sinks write to intermediate storage that the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Pickup Service][] reads.

<div class="mermaid">
graph LR
    subgraph "Application Server"
        roApp(fa:fa-code App with Nodinite Serilog sink)
    end
    subgraph "Nodinite Core Services Server"
        roLogAPI(fa:fa-cloud-arrow-down Log API)
        roPickup(fa:fa-truck-pickup Pickup Service)
    end
    subgraph "Azure Event Hubs / Service Bus"
        roSB(fa:fa-cloud *.servicebus.windows.net)
    end
    subgraph "Azure Storage"
        roBlob(fa:fa-cloud *.blob.core.windows.net)
    end
    subgraph "File share"
        roShare(fa:fa-folder Shared folder)
    end
    subgraph "DNS Server"
        roDNS(fa:fa-signs-post DNS)
    end
    roApp -.-> |"Log API site port"| roLogAPI
    roApp -.-> |"443, 5671-5672"| roSB
    roApp -.-> |"443"| roBlob
    roApp -.-> |"445"| roShare
    roPickup -.-> |"see Pickup Service"| roSB
    roPickup -.-> |"see Pickup Service"| roBlob
    roPickup -.-> |"see Pickup Service"| roShare
    roApp --> |"53"| roDNS
</div>

*Network diagram: each sink uses one dashed path; the Pickup Service collects from intermediate storage and posts to the Log API.*

### Between the application and the Log API

On [Windows Server][], <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> v7 hosts the [Log API][] as its own [IIS][] web site, on a port you set per environment in the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Portal ([Servers step][]); `NodiniteApiUrl` is `https://{host}:{port}/LogAPI/api/LogEvent`.

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Application Server|Core Services Server|TCP (HTTPS/HTTP)|Log API site port|Post Log Events ([Log API][Serilog - LogAPI] sink)|v7. No fixed default; no rule when the app runs on the Core Services Server|  

### Between the application and Azure Event Hubs or Service Bus

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Application Server|`*.servicebus.windows.net`|TCP|5671, 5672|AMQP|Default transport of the Azure SDK|  
|Outbound|Application Server|`*.servicebus.windows.net`|TCP|443|HTTPS, AMQP over WebSockets, Microsoft Entra ID tokens|Always open; 443 alone is enough with AMQP over WebSockets ([Event Hubs FAQ](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-faq#what-ports-do-i-need-to-open-on-the-firewall)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>)|  

### Between the application and Azure Blob Storage

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Application Server|`<account>.blob.core.windows.net`|TCP|443|HTTPS|Write Log Event blobs|  

### Between the application and the file share

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Application Server|File share|TCP|445|SMB|Only for a UNC path; a local folder needs no rule|  

### Between the Pickup Service and the intermediate storage

The [Pickup Service][] reads the Event Hub, Service Bus, Blob container, or folder and posts to the Log API; see the [Pickup Service firewall settings][Pickup firewall].

### Between the servers and DNS

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Application Server|DNS Server|TCP/UDP|53|Name resolution|Resolve the Log API host or the Azure endpoints|  

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p><strong>Stateful Firewalls</strong>: Response traffic for established outbound connections is allowed automatically.</p></div>
</aside>

___

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* [How To Start Logging With ILogger in Azure Functions][Serilog - ILogger] — Start logging in Azure Functions using Microsoft.Extensions.Logging.ILogger  
* [How To Start Logging With Serilog][Serilog - Logger] — Step-by-step guide to start logging with Serilog  
* [Configure Message Types][Message Types] — Make your Serilog data searchable and enable advanced features  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* [JSON Log Event][] — Understand the Nodinite JSON Log Event structure  
* [Log Events][Log Event] — Learn about Log Events in Nodinite  
* [Logging][] — Explore all Nodinite Logging capabilities  
* [Message Types][] — Critical for Search Field extraction from Serilog events  
* [Search Fields][] — Extract business data from logged messages  
* [Non-Events Monitoring][] — Track message volumes and patterns  
* [Business Process Modeling (BPM)][BPM] — End-to-end process tracking across Azure Functions, Logic Apps, and other systems  
* [Serilog - Common Questions (FAQ)][Serilog FAQ] — Quick answers about Serilog sinks, Message Types, Managed Identity, and costs  
* [Reduce Azure Functions Logging Costs][] — Lower the Azure cost of logging Azure Functions  
* [Azure Costs for Blob Storage and Event Hub][] — What staging log events in Azure costs  
* [Reduce Azure Logic Apps Run History Retention to Lower TCO][] — The same approach for Logic Apps  
* [Reduce Azure API Management Logging Costs][] — The same approach for API Management  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/SeriLog/NodiniteNugetSeriLogPackages.png
[2]:https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/SeriLog/ExtractExceptionUsingFormula.png

[Azure Costs for Blob Storage and Event Hub]:https://docs.nodinite.com/logging-and-monitoring/custom-logging/troubleshooting/azure-costs-for-blob-storage-and-event-hub/
[BPM]:https://docs.nodinite.com/repository-model/bpms/overview/
[Context Options]:https://docs.nodinite.com/core-services/log-event/features/context-options/
[Endpoint Directions]:https://docs.nodinite.com/core-services/log-event/features/endpoint-directions/
[Endpoints]:https://docs.nodinite.com/repository-model/endpoints/overview/
[EndpointTypes]:https://docs.nodinite.com/core-services/log-event/features/endpoint-types/
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[IIS]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/iis/
[JSON Log Event]:https://docs.nodinite.com/core-services/log-event/features/json-log-event/
[Log Agents]:https://docs.nodinite.com/administration/log-management/log-agents/features/what-is-a-log-agent/
[Log API]:https://docs.nodinite.com/core-services/log-api/overview/
[Log Event]:https://docs.nodinite.com/core-services/log-event/overview/
[Log Event Processing]:https://docs.nodinite.com/core-services/log-event/overview/
[Log Status Codes]:https://docs.nodinite.com/administration/log-management/log-agents/features/what-is-a-log-status-code/
[Log Views]:https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/
[Logging]:https://docs.nodinite.com/logging/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Microsoft Azure functions]:https://azure.microsoft.com/en-us/products/functions/
[Monitoring Service]:https://docs.nodinite.com/core-services/monitoring-service/overview/
[Non-Events Monitoring]:https://docs.nodinite.com/logging-and-monitoring/non-events/overview/
[Pickup firewall]:https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/getting-started/prerequisites/#fa-shield-check-firewall-requirements
[Pickup Log Events Service Logging Agent]:https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/overview/
[Pickup Service]:https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/overview/
[Reduce Azure API Management Logging Costs]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/troubleshooting/reduce-azure-api-management-logging-costs/
[Reduce Azure Functions Logging Costs]:https://docs.nodinite.com/logging-and-monitoring/serilog/troubleshooting/reduce-azure-functions-logging-costs/
[Reduce Azure Logic Apps Run History Retention to Lower TCO]:https://docs.nodinite.com/logging-and-monitoring/azure-logic-apps/troubleshooting/reduce-azure-logic-apps-run-history-retention-to-lower-tco/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[Search Fields]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/
[Serilog - Blob Storage]:https://docs.nodinite.com/logging-and-monitoring/serilog/features/blob-storage/
[Serilog - Event Hub]:https://docs.nodinite.com/logging-and-monitoring/serilog/features/event-hub/
[Serilog - File]:https://docs.nodinite.com/logging-and-monitoring/serilog/features/file/
[Serilog - ILogger]:https://docs.nodinite.com/logging-and-monitoring/serilog/how-to-start-logging-extending-ilogger/
[Serilog - LogAPI]:https://docs.nodinite.com/logging-and-monitoring/serilog/features/log-api/
[Serilog - Logger]:https://docs.nodinite.com/logging-and-monitoring/serilog/how-to-start-logging-with-serilog/
[Serilog - Service Bus]:https://docs.nodinite.com/logging-and-monitoring/serilog/features/servicebus/
[Serilog - Settings Section]:https://docs.nodinite.com/logging-and-monitoring/serilog/settings-section/
[Serilog FAQ]:https://docs.nodinite.com/logging-and-monitoring/serilog/troubleshooting/overview/
[Servers step]:https://docs.nodinite.com/install-and-update/getting-started/version-7/install-nodinite-v7-steps/04-servers/#core-platform-services
[URI]:https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
[Windows Authentication]:https://docs.nodinite.com/install-and-update/troubleshooting/iis/iis-authentication-settings/
[Windows Server]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/windows-server/