Skip to content

Commit 57cbe82

Browse files
Merge pull request #2604 from Kielek/splunk-otel-dotnet-1.9.0-log4net
Splunk OTel .NET 1.9.0 - log4net
2 parents 188db21 + b059e82 commit 57cbe82

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

gdi/get-data-in/application/otel-dotnet/instrumentation/connect-traces-logs.rst

+34-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Connect .NET trace data with logs using OpenTelemetry instrumentation
77
.. meta::
88
:description: Automatic correlation between logs and traces provided by the Splunk Distribution of OpenTelemetry .NET.
99

10-
The Splunk Distribution of OpenTelemetry .NET automatically exports logs enriched with tracing context from any application that uses logging API from :new-page:`Microsoft.Extensions.Logging <https://www.nuget.org/packages/Microsoft.Extensions.Logging>` for logging.
10+
The Splunk Distribution of OpenTelemetry .NET automatically exports logs enriched with tracing context from any application that uses logging API from:
11+
12+
* :new-page:`Microsoft.Extensions.Logging <https://www.nuget.org/packages/Microsoft.Extensions.Logging>`
13+
* :new-page:`log4net <https://www.nuget.org/packages/log4net>`
14+
1115

1216
Application logs are enriched with tracing metadata and then exported to a local instance of the OpenTelemetry Collector in ``OTLP`` format.
1317

@@ -48,9 +52,13 @@ The following is an example of logs produced by a sample console application:
4852
Check compatibility and requirements
4953
====================================================
5054

51-
.. note:: Automatic log to trace correlation only works for .NET applications. For .NET Framework use manual correlation. See :ref:`manual-trace-logs-correlation-otel`.
55+
.. note:: Automatic log to trace correlation for ``Microsoft.Extensions.Logging`` only works for .NET applications. For .NET Framework use manual correlation. See :ref:`manual-trace-logs-correlation-otel`.
5256

53-
``Microsoft.Extensions.Logging`` version ``9.0.0`` and higher are supported.
57+
The following applies:
58+
59+
* ``Microsoft.Extensions.Logging`` version ``9.0.0`` and higher are supported
60+
* ``log4net`` version from ``2.0.13`` to ``4.0.0`` are supported
61+
* The environmental variable ``OTEL_DOTNET_AUTO_LOGS_ENABLE_LOG4NET_BRIDGE`` needs to be set to ``true``
5462

5563
.. _dotnet-otel-enable-log-correlation:
5664

@@ -92,10 +100,31 @@ Additionally, the instrumentation adds the following attributes:
92100
Manual log to trace correlation
93101
===================================================
94102

95-
You can configure logging libraries to include tracing attributes in logs written to existing logs destination.
103+
You can configure logging libraries to include tracing attributes in logs written to existing log destinations.
104+
105+
``log4net``
106+
-----------------------------------------------
107+
108+
You can modify ``conversionPattern`` in your log4net appender to include tracing attributes in logs written to existing log destinations.
109+
110+
The following properties are set by default for the collection of logging events:
111+
112+
* `trace_id`
113+
* `span_id`
114+
* `trace_flags`
115+
116+
Example on how to configure ``ConsoleAppender``:
117+
118+
.. code-block:: text
119+
120+
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
121+
<layout type="log4net.Layout.PatternLayout">
122+
<conversionPattern value="%date [%thread] %-5level %logger - %message span_id=%property{span_id} trace_id=%property{trace_id} trace_flags=%property{trace_flags} test_key=%property{test_key}%newline" />
123+
</layout>
124+
</appender>
96125
97126
``NLog``
98-
----------------------------------------------------
127+
-----------------------------------------------
99128

100129
You can use :new-page:`NLog.DiagnosticSource <https://www.nuget.org/packages/NLog.DiagnosticSource>`. See the :new-page:`NLog official documentation <https://github.com/NLog/NLog.DiagnosticSource>` for more information.
101130

gdi/get-data-in/application/otel-dotnet/instrumentation/manual-dotnet-instrumentation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To create custom spans and traces, follow these steps:
2323

2424
.. code:: xml
2525
26-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
26+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
2727
2828
3. Create an ``ActivitySource`` instance:
2929

@@ -56,7 +56,7 @@ To create custom metrics, follow these steps:
5656

5757
.. code:: xml
5858
59-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
59+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
6060
6161
2. Create a ``Meter`` instance:
6262

0 commit comments

Comments
 (0)