DiscordLogSync
Pipes Valheim dedicated server logs to a Discord webhook in near-real-time. Configurable source: BepInEx pipeline, Console, or RawStdout (captures world saves and native stdout via fd-level intercepti
模組介紹 作者原文
DiscordLogSync — Valheim Dedicated Server Mod
Pipes Valheim dedicated server logs to a Discord webhook in near-real-time,
with local buffering so no lines are lost on unexpected process death.
How It Works
Server output (BepInEx pipeline, Console.Out, or raw stdout — see Source config)
│
▼
BepInEx/DiscordLogBuffer.txt ← every line flushed to disk immediately
│
▼ (background thread, every N seconds)
Discord Webhook POST
│
├─ success → remove sent lines from front of buffer (FIFO)
└─ failure → leave buffer intact, retry next tick
On startup:
buffer file exists from previous run? → send as ⚠️ crash-recovery message first
On clean shutdown:
flush remaining buffer as 🛑 shutdown message
Log Sources
Configure Source in the config file to choose what gets captured:
| Source | What it captures | Risk |
|--------|-----------------|------|
| BepInEx (default) | Everything flowing through BepInEx's log pipeline | Safe |
| Console | Managed Console.Out writes (superset of BepInEx in some cases) | Low |
| RawStdout | All stdout at the OS fd level — including world saves, ZDO counts, PlayFab lines that bypass BepInEx entirely | Experimental — read warning below |
⚠️ RawStdout Warning
RawStdout uses Linux pipe() + dup2() to replace fd 1 with a kernel pipe.
A background relay thread forwards every byte to the original stdout and extracts
lines for Discord. If the relay thread crashes or deadlocks, the pipe buffer
(~64 KB) will fill up and block all stdout writes in the entire process.
- Linux only — falls back to BepInEx source automatically on Windows or on any syscall failure
- Only enable this if you specifically need to capture native stdout output (e.g. world save events)
- Designed as a diagnostic tool, not a permanent production setting
Install
- Copy DiscordLogSync.dll into BepInEx/plugins/
- Launch the server once to generate the config file
- Open BepInEx/config/com.byawn.DiscordLogSync.cfg
- Set your webhook URL and preferred source:
[Discord]
Source = BepInEx
WebhookUrl =
SendIntervalSeconds = 3
MaxMessageChars = 1800
- Restart the server
Config Reference
| Key | Default | Description |
|-----|---------|-------------|
| Source | BepInEx | Log source: BepInEx, Console, or RawStdout (see above) |
| WebhookUrl | (empty) | Required. Discord webhook URL. Plugin does nothing if unset. |
| SendIntervalSeconds | 3 | Flush interval in seconds. Minimum 2 (Discord rate limit). |
| MaxMessageChars | 1800 | Max characters per Discord message. Hard Discord limit is 2000. |
Buffer File
BepInEx/DiscordLogBuffer.txt
- Every line is flushed to disk immediately — a hard kill loses at most the current line
- Treated as a FIFO queue: oldest lines sent first, newest preserved at the back
- If the file exists on startup, its contents are sent as a crash-recovery message before normal logging begins
Build
Requires.NET SDK with netstandard2.1 support and a Valheim dedicated server + BepInEx installation.
The.csproj assumes the default Linux Steam path:
~/.steam/steam/steamapps/common/Valheim dedicated server./build.sh # dotnet build -c Release./deploy_server.sh # copy DLL + config to local server./package.sh # zip ThunderstoreAssets + DLL for upload
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。 多人連線時,主機與所有用戶端需要安裝一致的模組。
下面這些內容需要先安裝,否則該模組不會生效: