Skip to main content
Use Foveus.Serilog to send structured Serilog logs to Foveus. This integration is for applications that already use Serilog. If your application does not use Serilog, you do not need Foveus.Serilog. Use Foveus.SDK alone.

How it works

Foveus.SDK captures executions, context, metrics, batching, transport, and correlation. Foveus.Serilog adds a Serilog sink so logs written through Serilog can be sent to Foveus. Use both packages together for Serilog-first applications.

Install packages

Install both packages:
During private beta, your package names or package source may be different. Use the package names and feed URL provided during onboarding.

Basic setup

Import the Foveus Serilog extension.
Configure Foveus first:
Then configure Serilog and add the Foveus sink:
Then add Foveus middleware if this is an ASP.NET Core API:
For Serilog-first applications, disable the built-in Foveus ILogger provider so logs are not captured twice.
Then configure Foveus and Serilog:

Keep using ILogger

You can keep using the standard .NET ILogger<T> APIs in a Serilog application.
In a Serilog-first app, those logs flow through Serilog’s normal .NET logging pipeline. Foveus captures them through the Serilog sink:
The key point:

Why disable the built-in logger provider?

In Serilog-first applications, you should usually disable the built-in Foveus ILogger provider. This does not mean you stop using ILogger<T>. You can keep writing normal .NET logs:
The difference is the path the log takes into Foveus.

Without Serilog

If you are not using Serilog, Foveus can capture ILogger<T> logs through the SDK logger provider.

With Serilog

If your app uses Serilog, ILogger<T> logs can flow through Serilog’s normal .NET logging pipeline. Foveus then captures them through the Serilog sink.
Then configure the Serilog sink:
This avoids duplicate log capture.

Why AddFoveus must run first

WriteTo.Foveus(services) uses dependency injection to get the Foveus services it needs. It pulls dependencies such as:
  • FoveusClient
  • FoveusOptions
  • IMetricsCollector
That means AddFoveus(...) must be registered before the Serilog sink is configured. Correct order:
Do not build a separate service provider just for Serilog.

Appsettings example

A typical Serilog-first setup looks like this:
Then configure the sink in code:

What gets captured

For each Serilog log event, Foveus captures structured log data.

Log level mapping

Foveus maps Serilog levels to Foveus log levels.

Structured logging

Serilog structured properties are sent to Foveus. This works whether the log call is written through Serilog directly or through ILogger<T> in a Serilog-configured application. Using ILogger<T>:
Using Serilog directly:
Foveus captures: Use structured properties for values you want to inspect or correlate later.

Exception logging

Serilog exceptions are captured with the log event. Using ILogger<T>:
Using Serilog directly:
Foveus captures:
  • exception type
  • exception message
  • stack trace
  • inner exception chain
  • rendered message
  • structured properties such as OrderId

Correlation

Foveus.Serilog tries to attach logs to the same execution, trace, and span as the rest of the telemetry. It gets correlation from:
  1. the current Foveus metrics/execution context
  2. System.Diagnostics.Activity.Current
  3. generated fallback IDs
When used with Foveus.SDK, logs can appear connected to requests, executions, traces, and errors in Foveus.

Using Serilog with ASP.NET Core

A typical setup for an ASP.NET Core API:

Using Serilog without HTTP middleware

You can use Foveus.Serilog in applications that do not receive HTTP requests. For example:
  • console apps
  • background jobs
  • workers
  • queue consumers
In these cases, Foveus can still receive structured logs. Full worker-service execution capture is not yet fully supported, but Serilog logs can still be sent when configured.
Worker service support is evolving. Foveus.Serilog can send structured logs from workers today, but full worker execution capture is not yet the same as HTTP execution capture.
For full worker setup details, see Worker services.

Redaction and safety

Log events can contain sensitive data. Avoid logging secrets, credentials, tokens, card data, or highly sensitive personal data. Use structured properties carefully.
If sensitive values are logged, they may be sent to Foveus. Use Serilog destructuring and filtering policies where appropriate, and keep Foveus redaction settings updated.

Troubleshooting

Logs are duplicated

If the same logs appear twice, both Foveus logging paths may be enabled:
  • the Foveus SDK logger provider
  • the Foveus Serilog sink
In Serilog-first apps, keep using ILogger<T>, but disable the Foveus SDK logger provider.
Then route logs to Foveus through:

Sink throws a setup error

Make sure you call AddFoveus(...) before configuring the sink.
The sink needs Foveus services from dependency injection.

Logs are not correlated to executions

Check that:
  • app.UseFoveus() is registered for HTTP services
  • logs are written during the request or operation
  • Activity/correlation context is available
  • WriteTo.Foveus(services) uses the app service provider
  • you are not building a separate service provider for Serilog

ILogger logs are not appearing

Check that your app is actually routing ILogger<T> logs through Serilog. In ASP.NET Core, make sure Serilog is configured on the host:
Then this should still work:

Logs do not appear

Check that:
  • both Foveus.SDK and Foveus.Serilog are installed
  • AddFoveus(...) is called
  • WriteTo.Foveus(services) is configured
  • the API key is valid
  • the dashboard is showing the right mode
  • the Serilog minimum level allows the event
  • the service can reach Foveus

Too many logs are sent

Adjust Serilog minimum levels.
You can also use Serilog filters to exclude noisy categories.

What to do next