Mark Ku's Blog

Setting Up a Lightweight Log Storage / Query / Analysis Service (Seq Log Server) on QNAP Docker Station — Using .NET Core + NLog as an Example

The Problem

As the number of websites and distributed services grows, debugging gets harder when logs are scattered across servers and containers. Tracking issues becomes painful, and the root cause is often hard to find. This is why introducing a log aggregation service really matters.

Evaluation

Common log aggregation options include ELK, Exceptionless, Seq, and Splunk. We used ELK at my previous company. ELK is feature-rich, but for a small team it's overkill to maintain — it also demands a lot more system resources. Personally, after using all of them, I prefer Seq's query interface.

Let's Set Up the Seq Log Server

Create > Search > seq > Click "datalust\seq" > Install

QNAP Container Station Docker Hub search highlighting datalust/seq image
QNAP Container Station Docker Hub search highlighting datalust/seq image

Set the environment variable to ACCEPT_EULA=Y

QNAP Docker container setup, ACCEPTEULA environment variable set to Y
QNAP Docker container setup, ACCEPTEULA environment variable set to Y

If you don't have a QNAP NAS, you can also install via Docker.

docker run --name seq -e ACCEPT_EULA=Y -p 8900:80 -p 5341:5341 datalust/seq
QNAP Container Station showing highlighted link icon for seq-1 container
QNAP Container Station showing highlighted link icon for seq-1 container

Next, create an API key for NLog to write logs

After entering the admin UI > click the account avatar > API KEYS

Seq admin UI dropdown menu with API keys option highlighted
Seq admin UI dropdown menu with API keys option highlighted

ADD API KEY > enter a name for the API key

Seq API key creation form with SHOP title and Ingest permissions
Seq API key creation form with SHOP title and Ingest permissions

Copy the generated API key into NLog's config file

UI dialog showing new Seq Log Server API key token (This token has been revoked.)

Open your .NET Core project and install the NLog extensions

NLog.Extensions.Logging // Skip logging from all Microsoft components
NLog.Targets.Seq

nlog.config configuration

<?xml version="1.0" encoding="utf-8"?>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwConfigExceptions="true"
      internalLogToConsole="true"
      internalLogLevel="Info" internalLogFile="D:\temp\nlog-internal.log"
	  >

  <!--加載ASP.NET Core插件-->
  <extensions>
    <add assembly="NLog.Web.AspNetCore" />
    <add assembly="NLog.Extensions.Logging" />
    <add assembly="NLog.Targets.Seq" />
  </extensions>

  <variable name="log-root" value="Log" />
  <variable name="log-daily" value="${log-root}/${date:format=yyyy-MM}/${shortdate}" />
  <!-- the targets to write to -->
  <targets>
     <target name="seq" xsi:type="BufferingWrapper" bufferSize="1000" flushTimeout="2000">
      <target xsi:type="Seq" serverUrl="http://{your seq server url}/" apiKey="{api key}">
        <property name="ThreadId" value="${threadid}" as="number" /> 
        <property name="MachineName" value="${machinename}" />
        <property name="Environment" value="${aspnet-environment}" />
        <property name="Logger" value="${logger}" />
        <property name="IP" value="${aspnet-request-ip}" />
        <property name="Url" value="${aspnet-request-url:IncludeHost=true:IncludePort=true:IncludeQueryString=true:IncludeScheme=true}" />
        <property name="Code" value="${aspnet-response-statuscode}" />
        <property name="TraceId" value="${aspnet-TraceIdentifier:ignoreActivityId=true}" />
        <property name="ActivityId" value="${activityid}" />
        <property name="RequestHeaders" value="${aspnet-request-headers:HeaderNames=Host,Referer,Origin,Authorization}" />
        <property name="RequestQueryString" value="${aspnet-request-querystring}" />
        <property name="RequestBody" value="${aspnet-request-posted-body}" />
        <property name="ClientIP" value="${aspnet-request-ip}" />
		<property name="Custom" value="${gdc:item=Custom}" />        
        <property name="CorrelationId" value="${aspnet-TraceIdentifier}" />
        <property name="AppName" value="Shop" />
      </target>
    </target>
  </targets>

  <!-- rules to map from logger name to target -->
  <rules>
    <!--跳過所有級別的Microsoft組件的日誌記錄-->
    <logger name="Microsoft.*" minlevel="Trace" final="true" />
	<!--跳过所有级别的CorrelationId组件的Info 層級下的 Log-->
    <logger name="CorrelationId.*" minlevel="Trace" maxlevel="Info" final="true" />
    <logger name="*" minlevel="Info" writeTo="seq" />
  </rules>
</nlog>

Once your sites and services start up, the log server will start receiving logs written by NLog from your .NET Core apps.

Seq log server dashboard showing a timeline of system events
Seq log server dashboard showing a timeline of system events

View error details

Seq log server UI displaying detailed error logs and signal filters
Seq log server UI displaying detailed error logs and signal filters

Filter by error level

Seq log server displaying error events with 'Errors' filter selected
Seq log server displaying error events with 'Errors' filter selected
Seq log server UI displaying InvalidOperationException errors with 'Errors' filt
Seq log server UI displaying InvalidOperationException errors with 'Errors' filt

Stats / report logs

Seq log server dashboard showing event graphs, error count, and distinct types
Seq log server dashboard showing event graphs, error count, and distinct types

Even cooler — you can query logs with SQL

Seq log server dashboard showing a message filter and error exceptions
Seq log server dashboard showing a message filter and error exceptions
Common Seq query examples

LIKE query
@Message like '%notify%'

Query Error level logs
@Level = 'Error'

Find logs related to 'shop'
app = 'shop'

Count logs by level
select count(1) from stream group by @Level

Query notify-related logs
select datepart( @Timestamp,'day',8h) as GMT8_Day,datepart( @Timestamp,'hour',8h)  as GMT8_Hour,  datepart( @Timestamp,'minute',8h)  as GMT8_Minute,ToIsoString(@Timestamp) as GMT0,  @Level, ToHexString(@EventType) as EventType,  @Message, @Exception, @Properties
from stream where @Message like 'notify%' 
order by GMT0 desc 

Wrap-up

Seq log server packs in a lot of features while staying lightweight. It's easy to configure, has low maintenance overhead, and is a great fit for small teams.

Bonus — Frontend logs can also be sent to a Seq server via seq-logging.

Frontend package on GitHub

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11