You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.**Duck Typing Integration**: Uses duck typing to avoid direct NLog assembly references
10
10
3.**Log Event Bridging**: Converting NLog log events to OpenTelemetry log records (when bridge is enabled)
11
11
4.**Structured Logging Support**: Leveraging NLog's layout abilities for enrichment
12
12
5.**Trace Context Injection**: Automatically injects trace context into NLog properties for all targets
13
-
6.**Custom Properties**: Forwarding custom properties while filtering internal NLog properties
13
+
6.**GlobalDiagnosticsContext Support**: Captures properties from NLog's GlobalDiagnosticsContext
14
+
7.**Custom Properties**: Forwarding custom properties while filtering internal NLog properties
14
15
15
16
**Note**: No NLog configuration changes are required. The instrumentation works exclusively through bytecode interception and relies on OpenTelemetry environment variables for configuration.
The instrumentation intercepts `NLog.Logger.Log` method calls at the bytecode level, allowing it to:
37
-
1.**Always inject trace context** into NLog's LogEventInfo properties (regardless of bridge status)
38
-
2.**Optionally forward logs** to OpenTelemetry when the bridge is enabled
39
+
The instrumentation intercepts NLog's internal `WriteToTargets` (NLog 5.x) and `WriteLogEventToTargets` (NLog 6.x) methods at the bytecode level. This ensures ALL log events are captured, including those from convenience methods like `log.Info()`, `log.Debug()`, etc.
39
40
40
41
## Components
41
42
42
43
### Core Components
43
44
44
-
#### Auto-Instrumentation Components
45
-
-**`ILoggingEvent.cs`**: Duck typing interface for NLog's LogEventInfo
46
-
-**`OpenTelemetryNLogConverter.cs`**: Internal converter that transforms NLog events to OpenTelemetry log records
47
-
-**`OpenTelemetryLogHelpers.cs`**: Helper for creating OpenTelemetry log records via expression trees
45
+
#### Duck Types (`ILoggingEvent.cs`)
46
+
-**`ILoggingEvent`**: Duck typing struct for NLog's LogEventInfo
47
+
-**`LoggingLevel`**: Duck typing struct for NLog's LogLevel
48
+
-**`IMessageTemplateParameters`**: Interface for structured logging parameters
48
49
49
-
### Integration
50
+
#### Bridge Components (`Bridge/`)
51
+
-**`OpenTelemetryNLogConverter.cs`**: Converts NLog events to OpenTelemetry log records
52
+
-**`OpenTelemetryLogHelpers.cs`**: Helper for creating OpenTelemetry log records via expression trees
50
53
51
-
-**`LoggerIntegration.cs`**: CallTarget integration that intercepts `NLog.Logger.Log` via bytecode instrumentation to capture log events
@@ -98,15 +108,17 @@ Trace context is **always injected** into NLog's LogEventInfo properties, regard
98
108
The following properties are injected when an active `Activity` exists:
99
109
-`TraceId`: The W3C trace ID
100
110
-`SpanId`: The W3C span ID
101
-
-`TraceFlags`: The W3C trace flags
111
+
-`TraceFlags`: The W3C trace flags ("01" if recorded, "00" otherwise)
102
112
103
113
#### OpenTelemetry Bridge
104
114
105
115
When `OTEL_DOTNET_AUTO_LOGS_ENABLE_NLOG_BRIDGE=true`, log events are additionally forwarded to OpenTelemetry's logging infrastructure for export via OTLP or other configured exporters.
106
116
107
117
## Supported Versions
108
118
109
-
-**NLog**: 5.0.0+ (required for Layout<T> typed layout support and .NET build-trimming)
0 commit comments