---
title: "Structured Logging in .NET with Serilog and ClickHouse"
description: "Traditional logging solutions like Seq, ELK, and cloud platforms often face scaling bottlenecks, including slower queries, higher operational costs, and complex pipeline management. To address this, an ASP.NET service can write structured logs directly to ClickHouse using Serilog and the Serilog.Sinks.ClickHouse library. The sink transmits data over HTTP and provides a fluent C# builder to configure table schemas, typed JSON columns, full-text indexes, and MergeTree engine parameters. ClickHouse stores log data in a columnar format that delivers 10 to 20 times compression while enabling direct SQL queries, JSON property filtering, and real-time aggregations through materialized views. Furthermore, the sink includes an in-memory buffer to handle transient network drops with configurable batching, retry mechanisms, and callback hooks for failure alerting."
---

# Structured Logging in .NET with Serilog and ClickHouse

[Clickhouse](https://yomu.fyi/company/clickhouse) · Alex Soffronow Pagonidis · Mar 23, 2026

**Type:** Tutorial

## Summary

Traditional logging solutions like Seq, ELK, and cloud platforms often face scaling bottlenecks, including slower queries, higher operational costs, and complex pipeline management. To address this, an ASP.NET service can write structured logs directly to ClickHouse using Serilog and the Serilog.Sinks.ClickHouse library. The sink transmits data over HTTP and provides a fluent C# builder to configure table schemas, typed JSON columns, full-text indexes, and MergeTree engine parameters. ClickHouse stores log data in a columnar format that delivers 10 to 20 times compression while enabling direct SQL queries, JSON property filtering, and real-time aggregations through materialized views. Furthermore, the sink includes an in-memory buffer to handle transient network drops with configurable batching, retry mechanisms, and callback hooks for failure alerting.

## Context

Scaling traditional .NET logging setups on Seq, ELK, or cloud platforms leads to higher costs, degraded query speeds, and difficult-to-manage pipelines as log volume grows.

## Approach / What changed

Stream structured logs directly from ASP.NET into ClickHouse using Serilog and Serilog.Sinks.ClickHouse, defining custom table schemas, typed JSON subcolumns, and inverted full-text indexes in C# code.

## Takeaways

- Serilog.Sinks.ClickHouse writes directly to ClickHouse via HTTP, allowing complete C# schema configuration including typed JSON subcolumns and text indexes.
- ClickHouse achieves 10x to 20x compression on structured logs and enables SQL-based querying, filtering, and real-time aggregation via materialized views.
- The Serilog ClickHouse sink buffers log events in memory and retries during flush cycles to handle brief network interruptions.

**Tags:** [Docker](https://yomu.fyi/topic/docker), [Observability](https://yomu.fyi/topic/observability), [Performance](https://yomu.fyi/topic/performance), [Scalability](https://yomu.fyi/topic/scalability)

- Source: [Clickhouse](https://clickhouse.com/blog/serilog)
- Source URL: https://clickhouse.com/blog/serilog
- Ingested by Yomu: 2026-08-28T01:22:50.917Z

[Read original post](https://clickhouse.com/blog/serilog)
