Skip to content

Releases

v3.3.0

Choose a tag to compare

@ozakboy ozakboy released this 13 Sep 19:45

Host-facing lifecycle control: LOG.Flush() / LOG.Shutdown() and their async counterparts, plus log files you can actually open while the process is running. Everything here is additive — no existing signature changed, no default value changed — so upgrading from 3.2.0 needs no code changes.

The reason this matters: logging is asynchronous, so until now there was no way to ask "is what I wrote actually on disk?" other than sleeping and hoping. Hosts that are about to be killed (container stop, crash handler, an app-wide finally) had no barrier to wait on, and anything that shut the logger down had no way to stop the background worker.

Added

LOG.Flush() — a real barrier, not a sleep

  • LOG.Flush() / LOG.Flush(int timeoutMs) blocks until every entry written so far has reached the disk, then returns true. Returns false on timeout (default 10 s) or when the logger is already shut down.
  • The calling thread helps drain the queue rather than waiting out the dispatcher's FlushIntervalMs, so the guarantee is exact: write 1000 entries, call Flush(), and the file has 1000 lines by the time it returns — no sleep, no re-read, no retry loop.
  • LOG.FlushAsync(CancellationToken) / LOG.FlushAsync(int timeoutMs, CancellationToken) return Task<bool> on every target framework, netstandard2.0 included. A cancelled token returns false rather than throwing OperationCanceledException.
  • Both pipelines (main logger and Quote) are flushed, and both force an fsync — the reason a host calls Flush is that the process may be killed next, so handing the buffer to the OS is not enough.

LOG.Shutdown() — stop the background work

  • LOG.Shutdown() / LOG.Shutdown(int timeoutMs) / LOG.ShutdownAsync(...): flush, then stop the dispatcher, the periodic disk-flush timer and the retention-cleanup timer, then close every open log file.
  • Idempotent. The first call returns true, later calls return false — that is a report, not an error. It also interleaves safely with the built-in ProcessExit / UnhandledException cleanup in either order, so a host that calls Shutdown() explicitly and then exits normally does not double-run the cleanup or trip over half-closed streams.
  • Writes after Shutdown are silently discarded — no exception, not even a console line. A background-logging library must not take its host down on the way out, and a host that is already shutting down should not have to guard every log statement. LOG.IsShutdown reports the current state.

Configure after Shutdown

  • LOG.Configure(...) remains non-reentrant while the pipeline is alive (unchanged v3.0 behavior — it exists so nobody swaps settings mid-run), but it is now allowed again after Shutdown: it restarts the pipeline and clears the discard state. That restriction only ever made sense while something was running.
  • The options are reset to defaults on restart, so the previous round's settings cannot linger as invisible state that nobody configured and nobody can see.

Fixed

Log files could not be opened by external tools while running

  • Files were opened with FileShare.Read, which only admits readers that open the file read-only. tail, editors and most log viewers open with FileAccess.ReadWrite and were rejected with a sharing violation — in practice, you could not watch the log while the process was running, which is most of the point of a local file logger.
  • Files are now opened with FileShare.ReadWrite (both the main logger and the Quote pipeline). The writer keeps its append-only handle; this only widens what other processes are permitted to do with the file.

Technical

  • Removed the DocumentationFile property from the project file. It pinned all five target frameworks to a single file.xml in the project directory (five builds racing to write the same file) and shipped the docs as lib/<tfm>/file.xml — a name IntelliSense ignores, since it only looks for <AssemblyName>.xml. The bilingual XML documentation was invisible to consumers all along. With only GenerateDocumentationFile left, each framework generates its own OzaLog.xml and the package now carries lib/<tfm>/OzaLog.xml, which IntelliSense picks up. The stale file.xml checked into the repository has been removed.
  • Both pipelines now track outstanding entries with a pending counter instead of inferring completion from an empty queue. An empty queue does not mean the work is done — the dispatcher may have dequeued an item that has not reached the file yet — and a Flush that trusted the queue would return one entry early. The counter is incremented before the enqueue for the same reason.
  • The dispatcher's semaphore and CancellationTokenSource are rebuilt on each Initialize, so the pipeline can genuinely restart after Shutdown; the ProcessExit / UnhandledException handlers are registered once per process, so a restart does not stack up duplicate cleanup handlers.
  • FileStreamPool.FlushAll and QuoteFileStreamPool.FlushAll gained a flushToDisk overload (the no-argument version keeps its existing behavior). The periodic timer still passes false — hand the buffer to the OS, throughput first; Flush / Shutdown pass true and force the fsync.
  • New internal coordinator LogLifecycle — the single place that owns the shutdown flag and sequences both pipelines, so LOG itself stays a thin facade.
  • New xUnit tests: LifecycleTests (a 1000-entry burst is exactly 1000 lines when Flush returns; writes after Shutdown throw nothing and leave no trace in any file; Shutdown is idempotent and survives the ProcessExit cleanup running afterwards; Configure stays non-reentrant until Shutdown; logging resumes after a restart) and FileShareTests (the file is readable and read-write openable while the writer holds it, and the writer keeps working afterwards). Cross-class test parallelization is disabled at assembly level, because shutting the pipeline down is process-global state and would otherwise cut other test classes off mid-write. 81 tests green (73 in 3.2.0).
  • Zero NuGet dependencies on net8.0 / net9.0 / net10.0 unchanged; build verified across all five target frameworks with 0 errors and 0 warnings.

Known limitations

  • Entries written within the same millisecond are not guaranteed to land in file order. The timestamp cache has 1 ms resolution and the queue is drained in batches. Use HighPrecisionTimestamp = true if you need to reorder entries after the fact. Not planned to change: the 1 ms cache is what keeps the caller-side cost at a few nanoseconds.
  • Synchronous mode (EnableAsyncLogging = false) still has no retention cleanup — KeepDays is enforced by a background cleaner that only the async pipeline starts. Carried over from 3.2.0.

v3.2.0

Choose a tag to compare

@ozakboy ozakboy released this 11 Sep 04:05

修正三個會影響日誌可信度的問題。

  • Error / Fatal 每筆重複寫入(舊版錯誤筆數是實際值的 1~2 倍浮動)
  • EnableAsyncLogging = false 時完全寫不出內容(檔案存在但 0 bytes)
  • 異常序列化的 JSON 帶加倍大括號,parser 讀不了

升 Minor 而非 Patch:三項都是使用者會實際觀察到的行為變更。公開 API 簽章未變。

詳見 https://github.com/ozakboy/OzaLog/blob/main/docs/zh-TW/changelog.md
NuGet: https://www.nuget.org/packages/OzaLog/3.2.0

v3.1.0

Choose a tag to compare

@ozakboy ozakboy released this 14 May 04:13

v3.1.0 — Custom time/thread display, multi-format output, Quote pipeline

Three new capabilities: customizable time/thread display, configurable output format (txt/log/json), and a dedicated Quote pipeline for high-frequency tick/quote data with Binance-aligned schema. All additions are backward compatible — defaults preserve v3.0 behavior.

Added

Customizable Time & Thread Display

  • LogOptions.TimeFormat (default "HH:mm:ss.fff") — free-form .NET DateTime format string for the message prefix. Falls back to default on parse failure.
  • LogOptions.ShowThreadId (default true) and LogOptions.ShowThreadName (default false) — independently toggle thread ID / name in the prefix. When ShowThreadName=true but the calling thread has no name (Thread.Name == null), the entire thread segment is omitted.
  • LogOptions.HighPrecisionTimestamp (default false) — opt-in Stopwatch-hybrid mode that reconstructs µs-level precision from the 1ms cache; raises caller-side ticks read cost from ~5ns to ~30ns.

Multiple Output Formats

  • LogOptions.OutputFormat (default LogOutputFormat.Txt) — global format selector: Txt / Log (same content, different extension) / Json (NDJSON with fixed schema {ts, lv, nm, tid?, tn?, msg, data?}).
  • JSON timestamps emit as epoch_ms integers. Field names use short forms (lv, nm, tid, tn) for compactness.

Quote (Tick/Ticker) Pipeline

  • LOG.Quote(...) and LOG.QuoteTicker(...) — public API for high-frequency quote/ticker data with field names aligned to Binance REST 24hr Ticker schema (Last, LastQty, Bid, BidQty, Ask, AskQty, Open, PrevClose, High, Low, Volume, QuoteVolume).
  • QuoteRecord (public readonly struct) — A2 core API for zero-allocation enqueue. Convenience A1 overloads for the common cases (tick only / bid+ask / full ticker / ticker+extras).
  • QuoteOptions (opt-in via opt.ConfigureQuote(q => q.Enable = true), default off) — independent async pipeline with its own dispatcher, queue, and FileStreamPool. Configurable OutputFormat (Txt/Log/Json), MaxOpenStreams (default 500), MaxQueueSize (default 50000), MaxBatchSize, FlushIntervalMs, OnDropped(long) callback.
  • QuoteRecord.Extras (IReadOnlyDictionary<string, object>) for flexible attributes and QuoteRecord.ExtrasJson (raw pre-serialized JSON string for the zero-overhead path) — mutually exclusive; setting both throws ArgumentException at the call site.
  • File naming: {baseDir}/{LogPath}/{yyyyMMdd}/{QuotePath}/{Bucket}_{Symbol}_Quote.{ext} — no nested subdirectories.
  • Symbol/bucket sanitization: file-system-invalid characters (/ \ : * ? " < > |) are automatically replaced with - in filenames; the original symbol/bucket text is preserved in the file content.

Tests

  • Four new xUnit test files covering custom time formats, NDJSON formatting, Quote schema/error scenarios, and filename sanitization (48 tests total, all passing).
  • OzaLog.Test/Program.cs rewritten to a comprehensive v3.1 smoke-test covering every API surface and error path in a single linear run, with optional CLI args for format selection (txt/log/json).

Improved

  • LogItem carries ThreadName so the dispatcher thread can render the calling thread's name (previously unavailable post-enqueue).
  • All Quote API overloads funnel through LOG.Quote(in QuoteRecord) for centralized validation. Errors (null/empty Symbol or Bucket, Extras/ExtrasJson both set, Extras key colliding with a reserved field) throw ArgumentException synchronously on the calling thread — not deferred to the dispatcher.
  • LogFormatter retains a fast path for the default HH:mm:ss.fff format (hand-written, zero-allocation); other formats route through DateTime.ToString with FormatException fallback to default.
  • FileStreamPool supports per-output extension (.txt / .log / .json) with corresponding part-detection logic for size-based file splitting.

Technical

  • System.Text.Json: bumped from 8.0.5 → 9.0.16 for netstandard2.0 / netstandard2.1 targets (net8.0 / net9.0 / net10.0 still use the BCL built-in — zero NuGet dependencies).
  • Microsoft.SourceLink.GitHub: bumped from 8.0.0 → 10.0.300 (build-only, PrivateAssets=all, no consumer impact).
  • New internal types: JsonLogFormatter, QuoteFormatter, QuoteFileStreamPool, QuoteLogHandler. Quote pipeline runs entirely in parallel with the main AsyncLogHandler — they share no locks or stream pools.
  • Build verified across all 5 TargetFrameworks (netstandard2.0 / netstandard2.1 / net8.0 / net9.0 / net10.0) with 0 errors.

📦 NuGet: https://www.nuget.org/packages/OzaLog/3.1.0
📖 Full changelog: https://github.com/ozakboy/OzaLog/blob/main/docs/en/changelog.md
🌐 Website: https://ozakboy.github.io/OzaLog/

v3.0.1

Choose a tag to compare

@ozakboy ozakboy released this 09 May 12:27

v3.0.1 — Metadata + repository improvements release

No library code changes — the OzaLog assembly is byte-identical to v3.0.0 (Deterministic build). Safe to upgrade with no compatibility risk.


🚀 Improved

  • NuGet package metadata refreshed:
    • Cleaner Description highlighting LOG.Info_Log("...") API + HFT pipeline + zero dependencies + crypto tick stream use case
    • Updated PackageTags: added ozalog, hft, high-performance, zero-dependency; removed misleading nlog tag
    • Polished Title
  • PackageReleaseNotes now uses absolute GitHub URLs for cross-references (NuGet doesn't render relative paths).

🛠️ Technical

  • New project website: Nuxt 4 + @nuxt/content + Tailwind CSS, deployed to GitHub Pages → https://ozakboy.github.io/OzaLog/
  • Repository documentation restructured: all user-facing docs moved to docs/{en,zh-TW}/ bilingual tree (changelog.md, migration.md, plus templates for getting-started.md, configuration.md, api.md, async-pipeline.md, benchmarks.md).
  • GitHub Actions auto-deploys site on push to main.
  • Sponsor page added (USDT BEP20 wallet + Binance Pay QR).
  • uplog release flow extended: now also creates GitHub Release and pushes to NuGet.org automatically.

📦 Install

dotnet add package OzaLog --version 3.0.1

🌐 Documentation


Disclaimer: OzaLog is not related to NLog (jkowalski's package). The previous version Ozakboy.NLOG was deprecated and renamed to OzaLog in v3.0 to avoid confusion.

v3.0.0

Choose a tag to compare

@ozakboy ozakboy released this 09 May 11:53

v3.0.0 — Major release: package rename + HFT-grade rewrite

Ozakboy.NLOG v2.x is now deprecated. Future development happens on OzaLog.
See migration guide (繁中: 升級指南).


⚠️ Breaking Changes

  • Package renamed: Ozakboy.NLOG → OzaLog. The previous package on NuGet is deprecated and points here.
  • Namespace renamed: ozakboy.LOG → OzaLog. All using statements in consumer code must be updated.
  • Removed TargetFrameworks: dropped .NET Framework 4.6.2, net6.0, net7.0 (all EOL). Now supports netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0.
  • Enum typo fixed: LogLevel.CostomName → LogLevel.CustomName. The public method LOG.CustomName_Log(...) was already correctly named — only the underlying enum value was renamed.

✨ Added

  • HFT-grade async pipeline: ConcurrentQueue<struct LogItem> + persistent FileStream pool + 1ms cached timestamp + drop-oldest backpressure.
  • New LogOptions:
    • EnableGlobalExceptionCapture (default false) — opt-in subscription to AppDomain.UnhandledException and TaskScheduler.UnobservedTaskException, auto-logs at Fatal level.
    • MaxOpenFileStreams (default 100) — LRU upper bound.
    • DiskFlushIntervalMs (default 100) — periodic flush interval for persistent FileStreams.
    • OnDropped (default null) — callback invoked when the async queue drops the oldest item under backpressure.
  • xUnit test project (OzaLog.Tests/) covering concurrency, LRU, day rollover, backpressure, GlobalExceptionCapture toggle, and format correctness.
  • BenchmarkDotNet project (OzaLog.Benchmarks/) comparing OzaLog with ZLogger, ZeroLog, and Serilog.

🚀 Improved

  • Zero NuGet dependencies on net8.0 / net9.0 / net10.0 (System.Text.Json built into BCL).
  • Formatting work moved off the calling thread — callers only enqueue raw tuples, no string.Format on the hot path.
  • Persistent FileStreams eliminate per-batch open/close, reducing syscall cost to near-zero.
  • Day rollover handled inline in the dispatcher.
  • Expired-log cleanup moved to a background timer (was on the hot path in v2.x).

🐛 Fixed

  • Double-format bug in LOG.cs where Console.WriteLine(formattedMessage, args) could throw FormatException if the formatted message coincidentally contained {0}-style tokens.
  • Auto-flush level selection — Error and Fatal now correctly trigger immediate flush regardless of the caller's immediateFlush argument.

🛠️ Technical

  • LogItem changed from class to readonly struct — zero GC on the hot path.
  • Build verified across all 5 TargetFrameworks with 0 warnings / 0 errors.

📦 Install

dotnet add package OzaLog --version 3.0.0

🌐 Documentation


Disclaimer: OzaLog is not related to NLog (jkowalski's package). The naming similarity in the previous version (Ozakboy.NLOG) caused confusion — v3.0 renames to OzaLog to make this unambiguous.

Version 2.1.0

Choose a tag to compare

@ozakboy ozakboy released this 24 Nov 14:39

1.新增 中英文備註
2.新增 英文介紹
Full Changelog: v2.0.0...v2.1.0

Version 2.0.0

Choose a tag to compare

@ozakboy ozakboy released this 12 Nov 13:12

重大更新

  1. 新增異步日誌系統

    • 新增異步日誌處理器 (AsyncLogHandler)
    • 提供智能批次處理機制
    • 可配置的隊列管理系統
    • 優化記憶體使用效率
  2. 新增配置系統

    • 新增 LogConfiguration 完整配置系統
    • 提供唯讀配置介面(ILogOptions)
    • 支援動態配置調整
    • 新增異步配置選項(AsyncLogOptions)
  3. 日誌檔案管理優化

    • 改進檔案分割機制
    • 支援自定義目錄結構
    • 智能檔案命名系統
    • 改進日誌清理機制
  4. 主要新增功能

    • 建立配置系統
    • 控制台輸出選擇
    • 同步/非同步寫入模式
    • 完整的執行緒安全設計

重要說明

  1. 建議在應用程式啟動時進行配置
  2. 異步模式為預設模式,可提供更好的效能
  3. 升級時請注意配置系統的變更
  4. 建議查看完整文檔以了解所有新功能
  5. 方法名稱異動 CostomName_Log =>CustomName_Log

未來展望

  1. 計劃加入更多日誌格式支援
  2. 新增更多自定義選項

變更日誌

v1.2.1...v2.0.0

Version v1.2.1

Choose a tag to compare

@ozakboy ozakboy released this 08 Nov 07:18
  1. 調整框架支援版本

    • 刪除 .NET Core 3.1 支援
    • 新增 .NET 8.0 支援
    • 降低框架需求至 .NET Framework 4.6.2
  2. 優化 System.Text.Json 版本需求

    • .NET Framework 4.6.2:使用 System.Text.Json 8.0.5
    • .NET Standard 2.0/2.1:使用 System.Text.Json 6.0.10
    • .NET 6.0/7.0/8.0:使用 System.Text.Json 8.0.5
  3. 改善例外處理機制

    • 強化例外資訊序列化功能
    • 完整記錄內部例外(InnerException)資訊
    • 新增例外額外屬性的序列化支援
    • 優化例外堆疊追蹤的格式化輸出
    • 自動處理例外物件的循環參考問題
  4. 修正多執行緒環境下的日誌寫入問題

  5. 優化大型物件序列化效能

Version 1.1.6

Choose a tag to compare

@ozakboy ozakboy released this 30 Jun 02:27
  1. 新增 .NET Standard 的支援
  2. 向下支援 .net Framework 的應用

Version 1.1.2

Choose a tag to compare

@ozakboy ozakboy released this 02 Apr 20:10
  1. 針對 .net 7 支援