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
This ensures we can specify file logging globally and uniformly. Greatly simplifying the debug-ability of the agent.
The preferred way is to set any or all of the following:
* `ELASTIC_OTEL_LOG_TARGETS` (to anything but `none`)
* if only set to `stdout` no file will be created but global logging will kicking )
* `OTEL_DOTNET_AUTO_LOG_DIRECTORY`
* `OTEL_LOG_LEVEL`
* `trace` `debug` will enable global file logging if the other two variables are not set explicitly.
This ensure we have one way to debug both our proprietary agent as well as the [Elastic OpenTelemetry Distribution](https://github.com/elastic/elastic-otel-dotnet).
See: elastic/elastic-otel-dotnet#129
For backwards compatible reasons the profiler variables are also supported:
* `ELASTIC_APM_PROFILER_LOG`
* `ELASTIC_APM_PROFILER_LOG_DIR`
* `ELASTIC_APM_PROFILER_LOG_TARGETS`
Globally setting
* `ELASTIC_APM_LOG_LEVEL` and `ELASTIC_APM_LOG_DIRECTORY` is also supported but not preferred.
Setting these in any of our supported deploy scenarios:
* Manual instrumentation (nuget)
* ASP.NET (classic)
* ASP.NET core
* NOTE: we now log to both the configured ILogger and our global logging.
* Auto Instrumentation
* Profiler
* Startup hooks
To keep support existing deploys this now always globally logs to file if only `ELASTIC_APM_STARTUP_HOOKS_LOGGING` is set as well.
This further updates our docs for the profiler and troubleshooting to prefer `ELASTIC_OTEL_*` variables.
The profiler is updated to read the same environment variables as managed code.
with the source name `"Elastic.Apm"`. The TraceSource adheres to the log levels defined in the
73
-
APM agent configuration. Typically, you will configure a preferred log level using an application setting in `web.config`.
74
-
75
-
[IMPORTANT]
76
-
--
77
-
System.Diagnostics.TraceSource requires the https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/how-to-compile-conditionally-with-trace-and-debug[`TRACE` compiler directive to be specified], which is specified
78
-
by default for both Debug and Release build configurations.
can be configured to monitor log messages for the trace source, using the https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/trace-debug/system-diagnostics-element[`<system.diagnostics>`] section of
83
-
web.config. For example, the following web.config section writes Elastic.Apm log messages to a file
84
-
named my_log_file.log:
85
-
86
-
[source,xml]
87
-
----
88
-
<configuration>
89
-
<!-- other sections .... -->
90
-
<system.diagnostics>
91
-
<sources>
92
-
<source name="Elastic.Apm"> <1>
93
-
<listeners>
94
-
<add name="file"
95
-
type="System.Diagnostics.TextWriterTraceListener"
96
-
initializeData="my_log_file.log" />
97
-
</listeners>
98
-
</source>
99
-
</sources>
100
-
</system.diagnostics>
101
-
</configuration>
102
-
----
103
-
<1> Define listeners under a source with name `"Elastic.Apm"` to capture agent logs
104
-
105
116
[float]
106
117
[[collect-logs-class-other-logging-systems]]
107
-
===== Other logging systems
118
+
==== Other logging systems
108
119
109
120
If you have a logging system in place such as https://nlog-project.org/[NLog], https://serilog.net/[Serilog],
110
121
or similar, you can direct the agent logs into your logging system by creating an adapter between
@@ -242,17 +253,7 @@ The agent is only supported on IIS7 and higher where the `Integrated Pipeline Mo
242
253
[[startup-hook-failure]]
243
254
=== Startup hooks failure
244
255
245
-
If the <<zero-code-change-setup, startup hook>> integration throws an exception, additional detail can be obtained by
246
-
setting the `ELASTIC_APM_STARTUP_HOOKS_LOGGING` environment variable before starting the application
247
-
248
-
[source,sh]
249
-
----
250
-
set ELASTIC_APM_STARTUP_HOOKS_LOGGING=1
251
-
----
252
-
253
-
and then running the application in a context where the environment variable will be visible. In setting this value,
254
-
an `ElasticApmAgentStartupHook.log` file is written to the directory containing the startup hook assembly, in addition to
255
-
writing to standard output.
256
+
If the <<zero-code-change-setup, startup hook>> integration throws an exception, additional detail can be obtained through <<collect-logs-globally, enabling the global log collection>>.
0 commit comments