Skip to content

Commit c19d7ec

Browse files
committed
refactor(documentation): update
1 parent 169dca0 commit c19d7ec

32 files changed

Lines changed: 575 additions & 57 deletions

documentation/simplew/docs/.vitepress/config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ export default defineConfig({
123123
text: 'Helpers',
124124
items: [
125125
{ text: 'Hosting', link: '/addons/hosting' },
126+
{ text: 'Log4net', link: '/addons/log4net' },
126127
{ text: 'Razor', link: '/addons/razor' },
128+
{ text: 'Serilog', link: '/addons/serilog' },
127129
{ text: 'Swagger', link: '/addons/swagger' },
128130
]
129131
},
@@ -151,6 +153,7 @@ export default defineConfig({
151153
{ text: 'HttpRequest', link: '/reference/httprequest' },
152154
{ text: 'HttpResponse', link: '/reference/httpresponse' },
153155
{ text: 'HttpHeaders', link: '/reference/httpheaders' },
156+
{ text: 'HttpBag', link: '/reference/httpbag' },
154157
]
155158
},
156159
{

documentation/simplew/docs/addons/firewall.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Firewall
22

3-
[`SimpleW.Service.Firewall`](https://www.nuget.org/packages/SimpleW.Service.Firewall) is an optional **application-level firewall module** for the SimpleW web server.
4-
It provides **fast IP filtering and rate limiting**, implemented as a SimpleW middleware.
3+
The [`SimpleW.Service.Firewall`](https://www.nuget.org/packages/SimpleW.Service.Firewall) package provides an **application-level firewall module** for the SimpleW web server. It is implemented as a SimpleW middleware.
54

65

76
## Features
@@ -31,7 +30,7 @@ Optional dependency if you enable GeoIP country filtering :
3130
## Installation
3231

3332
```sh
34-
$ dotnet add package SimpleW.Service.Firewall --version 26.0.0-beta.20260304-1501
33+
$ dotnet add package SimpleW.Service.Firewall --version 26.0.0-beta.20260307-1526
3534
```
3635

3736

documentation/simplew/docs/addons/hosting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hosting
22

3-
[`SimpleW.Helper.Hosting`](https://www.nuget.org/packages/SimpleW.Helper.Hosting) is an optional integration package that allows you to run a **SimpleW server** using the **Microsoft.Extensions.Hosting** infrastructure.
3+
The [`SimpleW.Helper.Hosting`](https://www.nuget.org/packages/SimpleW.Helper.Hosting) package provides an helper that allows you to run a **SimpleW server** using the **Microsoft.Extensions.Hosting** infrastructure.
44

55
It is designed for developers who are used to the .NET *Generic Host* model and want :
66
- standard application lifecycle management
@@ -35,7 +35,7 @@ It allows you to :
3535
Install the package from NuGet:
3636

3737
```sh
38-
$ dotnet add package SimpleW.Helper.Hosting --version 26.0.0-beta.20260304-1501
38+
$ dotnet add package SimpleW.Helper.Hosting --version 26.0.0-beta.20260307-1526
3939
```
4040

4141

documentation/simplew/docs/addons/latency.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Latency
22

33
The [`SimpleW.Service.Latency`](https://www.nuget.org/packages/SimpleW.Service.Latency) package provides a **latency injection module** for the SimpleW web server.
4+
It is implemented as a SimpleW middleware.
45

56

67
## Features
@@ -25,7 +26,7 @@ No external dependencies.
2526
## Installation
2627

2728
```sh
28-
$ dotnet add package SimpleW.Service.Latency --version 26.0.0-beta.20260304-1501
29+
$ dotnet add package SimpleW.Service.Latency --version 26.0.0-beta.20260307-1526
2930
```
3031

3132

documentation/simplew/docs/addons/letsencrypt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LetsEncrypt
22

3-
[`SimpleW.Service.Letsencrypt`](https://www.nuget.org/packages/SimpleW.Service.Letsencrypt) provides automatic TLS certificate management for SimpleW using **Let's Encrypt** and the **ACME HTTP-01 challenge**.
3+
The [`SimpleW.Service.Letsencrypt`](https://www.nuget.org/packages/SimpleW.Service.Letsencrypt) package provides automatic TLS certificate management for SimpleW using **Let's Encrypt** and the **ACME HTTP-01 challenge**. It is implemented as a SimpleW middleware.
44

55
Its goal is simple: enable HTTPS with real certificates, keep them renewed automatically, and stay minimal and predictable — fully aligned with SimpleW's philosophy.
66

@@ -29,7 +29,7 @@ It allows you to :
2929
## Installation
3030

3131
```sh
32-
$ dotnet add package SimpleW.Service.Letsencrypt --version 26.0.0-beta.20260304-1501
32+
$ dotnet add package SimpleW.Service.Letsencrypt --version 26.0.0-beta.20260307-1526
3333
```
3434

3535

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Log4net
2+
3+
The [`SimpleW.Helper.Log4net`](https://www.nuget.org/packages/SimpleW.Helper.Log4net) package provides a **bridge between the SimpleW internal logging system and log4net**.
4+
5+
It allows all logs emitted through `SimpleW.Observability.Log` to be automatically forwarded to a **log4net** `ILog` instance.
6+
7+
This integration keeps the **SimpleW logging API lightweight and allocation-friendly**, while letting developers use the mature log4net ecosystem (appenders, layouts, filters, etc.).
8+
9+
10+
## Features
11+
12+
It allows you to :
13+
- Forward all **SimpleW logs** to log4net
14+
- Automatically **detect the minimum logging level** from the provided log4net logger
15+
- Preserve **TraceId / SpanId** from `System.Diagnostics.Activity`
16+
- Attach the SimpleW **log source** as a log4net property
17+
- Add **custom enrichers**
18+
19+
20+
## Requirements
21+
22+
- .NET 8.0
23+
- SimpleW (core server)
24+
- Log4net (>= 3.2)
25+
26+
27+
## Installation
28+
29+
```sh
30+
$ dotnet add package SimpleW.Helper.Log4net --version 26.0.0-beta.20260202-1339
31+
```
32+
33+
34+
## Configuration options
35+
36+
| Option | Default | Description |
37+
| ------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38+
| MinimumLevel | `auto` | Overrides the SimpleW global minimum log level. When `null`, the level is automatically detected from the provided log4net logger. |
39+
| Mode | `SinkMode.Add` | Determines how the log4net bridge is attached. `Add` chains the sink with existing SimpleW sinks. `Replace` replaces the current SimpleW sink entirely. |
40+
| IncludeSource | `true` | When enabled, the SimpleW log source (`entry.Source`) is attached to the log4net context properties. |
41+
| IncludeTraceAndSpan | `true` | When an active `System.Diagnostics.Activity` exists, the bridge adds `trace_id` and `span_id` properties to the log event. |
42+
| SourcePropertyName | `"simplew_source"` | Name of the log4net property used to store the SimpleW log source. |
43+
| TraceIdPropertyName | `"trace_id"` | Name of the property used to store the `Activity.TraceId`. |
44+
| SpanIdPropertyName | `"span_id"` | Name of the property used to store the `Activity.SpanId`. |
45+
| Enricher | `null` | Optional callback allowing custom enrichment of the log4net properties for each log entry. Receives `(IDictionary<string, object?> properties, LogEntry entry)`. |
46+
47+
48+
## Minimal Example
49+
50+
Configure a simple log4net console logger in code :
51+
52+
```csharp
53+
using log4net;
54+
using log4net.Appender;
55+
using log4net.Layout;
56+
using log4net.Repository.Hierarchy;
57+
using SimpleW.Helper.Log4net;
58+
59+
var hierarchy = (Hierarchy)LogManager.GetRepository();
60+
61+
var layout = new PatternLayout("%date %-5level %message%newline");
62+
layout.ActivateOptions();
63+
64+
var consoleAppender = new ConsoleAppender {
65+
Layout = layout
66+
};
67+
consoleAppender.ActivateOptions();
68+
69+
hierarchy.Root.AddAppender(consoleAppender);
70+
hierarchy.Root.Level = log4net.Core.Level.Info;
71+
hierarchy.Configured = true;
72+
73+
ILog logger = LogManager.GetLogger(typeof(Program));
74+
```
75+
76+
Install the bridge :
77+
78+
```csharp
79+
var bridge = SimpleWLog4NetBridge.Install(logger, configure: options => {
80+
options.IncludeSource = true;
81+
});
82+
```
83+
84+
Once installed, every log emitted via :
85+
86+
```csharp
87+
Log.Info("MySource", "Hello world");
88+
```
89+
90+
will be forwarded to Log4net.
91+
92+
93+
## Automatic Minimum Level Detection
94+
95+
When installing the bridge, SimpleW automatically detects the minimum level enabled in the log4net logger.
96+
97+
Example :
98+
99+
```csharp
100+
hierarchy.Root.Level = log4net.Core.Level.Warn;
101+
```
102+
103+
The bridge will automatically configure:
104+
105+
```csharp
106+
SimpleW.Log.MinimumLevel = Warning
107+
```
108+
109+
This ensures that disabled log levels are filtered **before log creation**, preserving the performance characteristics of SimpleW logging.
110+
111+
112+
## Replace vs Add Sink
113+
114+
By default the bridge adds a sink.
115+
116+
```csharp
117+
options.Mode = SinkMode.Add;
118+
```
119+
120+
This allows multiple logging targets.
121+
122+
Example :
123+
124+
```
125+
SimpleW
126+
├─ Console sink
127+
└─ log4net bridge
128+
```
129+
130+
If you want Log4net to be the only logging target, replace the sink:
131+
132+
```csharp
133+
SimpleWLog4netBridge.Install(logger, replaceExistingSink: true);
134+
```
135+
136+
137+
## Activity / Distributed Tracing
138+
139+
When a `System.Diagnostics.Activity` is active (for example when using OpenTelemetry), the bridge automatically attaches :
140+
141+
```
142+
trace_id
143+
span_id
144+
```
145+
146+
These properties are stored in **log4net LogicalThreadContext properties**, allowing layouts such as :
147+
148+
```
149+
%date %-5level %property{trace_id} %property{span_id} %message%newline
150+
```
151+
152+
This allows log4net logs to correlate with distributed traces.
153+
154+
SimpleW telemetry is based on `System.Diagnostics.Activity` and integrates naturally with the OpenTelemetry ecosystem.

documentation/simplew/docs/addons/newtonsoft.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Newtonsoft
22

3-
[`SimpleW.JsonEngine.Newtonsoft`](https://www.nuget.org/packages/SimpleW.JsonEngine.Newtonsoft) is an optional integration package that allows you to run a **SimpleW server** using the **Microsoft.Extensions.Hosting** infrastructure.
3+
The [`SimpleW.JsonEngine.Newtonsoft`](https://www.nuget.org/packages/SimpleW.JsonEngine.Newtonsoft) is an optional integration package that allows you to run a **SimpleW server** using the **Microsoft.Extensions.Hosting** infrastructure.
44

55

66
## Using Newtonsoft.Json
@@ -9,10 +9,18 @@ Some projects require features or behaviors that are specific to [Newtonsoft.Jso
99

1010
For this reason, SimpleW provides an official alternative engine via the `SimpleW.JsonEngine.Newtonsoft` package.
1111

12+
13+
## Requirements
14+
15+
- .NET 8.0
16+
- SimpleW (core server)
17+
- Newtonsoft.Json package (automatically included)
18+
19+
1220
#### Installation
1321

1422
```sh
15-
$ dotnet add package SimpleW.JsonEngine.Newtonsoft --version 26.0.0-beta.20260304-1501
23+
$ dotnet add package SimpleW.JsonEngine.Newtonsoft --version 26.0.0-beta.20260307-1526
1624
```
1725

1826

documentation/simplew/docs/addons/openid.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# OpenID
22

3-
[`SimpleW.Service.OpenID`](https://www.nuget.org/packages/SimpleW.Service.OpenID) is an OpenID Connect (OIDC) authentication module for the SimpleW web server.
3+
The [`SimpleW.Service.OpenID`](https://www.nuget.org/packages/SimpleW.Service.OpenID) package provides an OpenID Connect (OIDC) authentication for the SimpleW web server.
4+
It is implemented as a SimpleW middleware.
45

56
It allows SimpleW applications to authenticate users using external identity providers such as **Google, Apple, Azure AD**, or **Keycloak**, using the standard **Authorization Code flow**.
67

@@ -31,7 +32,7 @@ It allows you to :
3132
## Installation
3233

3334
```sh
34-
$ dotnet add package SimpleW.Service.OpenID --version 26.0.0-beta.20260304-1501
35+
$ dotnet add package SimpleW.Service.OpenID --version 26.0.0-beta.20260307-1526
3536
```
3637

3738

documentation/simplew/docs/addons/razor.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ It allows you to :
2626
- SimpleW (core server)
2727
- RazorLight package (automatically included)
2828

29-
No external dependencies.
30-
3129

3230
## Installation
3331

3432
```sh
35-
$ dotnet add package SimpleW.Helper.Razor --version 26.0.0-beta.20260304-1501
33+
$ dotnet add package SimpleW.Helper.Razor --version 26.0.0-beta.20260307-1526
3634
```
3735

3836

0 commit comments

Comments
 (0)