@@ -4,165 +4,45 @@ title: "User Guide"
44
55# User Guide
66
7- This guide helps you adopt ` XenoAtom.Logging ` in production without getting overwhelmed:
7+ ![ XenoAtom.Logging demo screenshot ] ( ../img/screenshot.png ) {.terminal}
88
9- - Start with a minimal setup.
10- - Choose sync or async behavior intentionally.
11- - Add structure, sinks, and formatting incrementally.
9+ Welcome to the XenoAtom.Logging documentation.
1210
13- If you are new to the library, begin with [ Getting Started ] ( getting-started.md ) .
11+ This section is organized as a practical map: start quickly, then go deeper by topic based on your use case .
1412
15- ## Installation
13+ ## Start here
1614
17- Core package:
15+ - [ Getting Started] ( getting-started.md ) : install packages, configure logging, and run your first sync/async setup.
16+ - [ Migration from Microsoft.Extensions.Logging] ( microsoft-extensions-logging.md ) : API mapping and rollout guidance.
17+ - [ Package Consumption Guide] ( packages.md ) : package layout and when to use each package.
1818
19- ``` sh
20- dotnet add package XenoAtom.Logging
21- ```
19+ ## Core runtime topics
2220
23- Optional terminal package:
21+ - [ Filtering and Routing] ( filtering.md ) : logger hierarchy, writer fan-out, and filters.
22+ - [ File and JSON Writers] ( file-writer.md ) : rolling files, retention, JSONL output, and failure handling.
23+ - [ Shutdown Semantics] ( shutdown.md ) : flushing and lifecycle behavior at app exit.
24+ - [ Thread Safety] ( thread-safety.md ) : what is safe concurrently and what must be configured carefully.
2425
25- ``` sh
26- dotnet add package XenoAtom.Logging.Terminal
27- ```
26+ ## Formatting and generated APIs
2827
29- ## A minimal working setup
28+ - [ Log Formatters] ( log-formatter.md ) : built-in formatters, template syntax, and custom formatter generation.
29+ - [ Source-generated Logging] ( source-generator.md ) : ` [LogMethod] ` and diagnostics.
3030
31- ``` csharp
32- using XenoAtom .Logging ;
33- using XenoAtom .Logging .Writers ;
31+ ## Terminal and UI output
3432
35- var config = new LogManagerConfig
36- {
37- RootLogger =
38- {
39- MinimumLevel = LogLevel .Info ,
40- Writers =
41- {
42- new FileLogWriter (" logs/app.log" )
43- }
44- }
45- };
33+ - [ Terminal Integration] ( terminal.md ) : ` TerminalLogWriter ` , ` TerminalLogControlWriter ` , markup, and styling.
34+ - [ Terminal Visual Examples] ( terminal-visuals.md ) : rendered examples and styling walkthrough.
4635
47- LogManager . Initialize ( config );
36+ ## Performance and deployment
4837
49- var logger = LogManager . GetLogger ( " App.Main " );
50- logger . Info ( " Application started " );
38+ - [ Benchmarks ] ( benchmarks.md ) : benchmark setup, scenarios, and interpretation guidance.
39+ - [ Native AOT and Trimming ] ( aot.md ) : AOT/trimming-oriented behavior and constraints.
5140
52- LogManager .Shutdown ();
53- ```
41+ ## Recommended reading order
5442
55- ## Core concepts
56-
57- ### 1) Lifecycle
58-
59- - ` LogManager.Initialize(...) ` for synchronous processing.
60- - ` LogManager.InitializeForAsync(...) ` for queued asynchronous processing.
61- - ` LogManager.Shutdown() ` to flush and dispose writers.
62-
63- ### 2) Logger hierarchy
64-
65- - ` RootLogger ` defines defaults (level, writers, overflow mode).
66- - ` Loggers.Add("App.Http", ...) ` overrides by name prefix.
67- - ` includeParents ` controls whether parent/root writers are inherited.
68-
69- See [ Filtering and Routing] ( filtering.md ) .
70-
71- ### 3) Structured data
72-
73- - Per-message properties with ` LogProperties ` .
74- - Scoped properties with ` BeginScope ` .
75-
76- ``` csharp
77- logger .Info (
78- properties : new LogProperties { (" requestId" , 1423 ), (" tenant" , " alpha" ) },
79- msg : " Processing request" );
80- ```
81-
82- ## Choosing sync vs async
83-
84- Use sync mode when sink I/O is low latency and predictable.
85-
86- Use async mode when throughput is high or when sink I/O can block:
87-
88- ``` csharp
89- config .AsyncLogMessageQueueCapacity = 4096 ;
90- config .AsyncErrorHandler = ex => Console .Error .WriteLine (ex .Message );
91- config .RootLogger .OverflowMode = LoggerOverflowMode .Block ;
92-
93- LogManager .InitializeForAsync (config );
94- ```
95-
96- Overflow guidance:
97-
98- - ` Block ` : safest for correctness (recommended default for critical logs).
99- - ` Drop ` / ` DropAndNotify ` : lower producer latency, but allow loss.
100- - ` Allocate ` : temporary queue growth under pressure.
101-
102- See [ Shutdown Semantics] ( shutdown.md ) and [ Thread Safety] ( thread-safety.md ) for operational behavior.
103-
104- ## Writer choices
105-
106- ### File and JSON pipelines
107-
108- - ` FileLogWriter ` for rolling text logs.
109- - ` JsonFileLogWriter ` for JSONL ingestion pipelines.
110-
111- See [ File and JSON Writers] ( file-writer.md ) .
112-
113- ### Terminal and UI rendering
114-
115- - ` TerminalLogWriter ` for terminal output.
116- - ` TerminalLogControlWriter ` for ` XenoAtom.Terminal.UI ` ` LogControl ` .
117- - ` InfoMarkup ` /` ErrorMarkup ` for markup-aware payloads.
118-
119- See [ Terminal Integration] ( terminal.md ) and [ Terminal Visual Examples] ( terminal-visuals.md ) .
120-
121- ## Formatter choices
122-
123- Text formatters:
124-
125- - ` StandardLogFormatter `
126- - ` CompactLogFormatter `
127- - ` DetailedLogFormatter `
128-
129- Custom text formatters:
130-
131- - ` [LogFormatter("...")] ` on partial records
132- - shared runtime formatter settings (` LevelFormat ` , ` TimestampFormat ` )
133-
134- See [ Log Formatters] ( log-formatter.md ) .
135-
136- ## Source-generated logging methods
137-
138- Use ` [LogMethod] ` to define strongly-typed logging APIs:
139-
140- ``` csharp
141- public static partial class AppLogs
142- {
143- [LogMethod (LogLevel .Info , " User {userId} connected" )]
144- public static partial void UserConnected (Logger logger , int userId );
145- }
146- ```
147-
148- See [ Source-generated Logging] ( source-generator.md ) .
149-
150- ## Coming from Microsoft.Extensions.Logging
151-
152- Use [ Migration from Microsoft.Extensions.Logging] ( microsoft-extensions-logging.md ) for API mapping and rollout guidance.
153-
154- ## Documentation map
155-
156- - [ Getting Started] ( getting-started.md )
157- - [ Migration from Microsoft.Extensions.Logging] ( microsoft-extensions-logging.md )
158- - [ Package Consumption Guide] ( packages.md )
159- - [ Log Formatters] ( log-formatter.md )
160- - [ Source-generated Logging] ( source-generator.md )
161- - [ Filtering and Routing] ( filtering.md )
162- - [ File and JSON Writers] ( file-writer.md )
163- - [ Terminal Integration] ( terminal.md )
164- - [ Terminal Visual Examples] ( terminal-visuals.md )
165- - [ Thread Safety] ( thread-safety.md )
166- - [ Shutdown Semantics] ( shutdown.md )
167- - [ Native AOT and Trimming] ( aot.md )
168- - [ Benchmarks] ( benchmarks.md )
43+ 1 . [ Getting Started] ( getting-started.md )
44+ 2 . [ Filtering and Routing] ( filtering.md )
45+ 3 . [ File and JSON Writers] ( file-writer.md )
46+ 4 . [ Log Formatters] ( log-formatter.md )
47+ 5 . [ Thread Safety] ( thread-safety.md )
48+ 6 . [ Shutdown Semantics] ( shutdown.md )
0 commit comments