Elastic APM with ASP.Net Web Forms

Hi all,
I'm trying to integrate my web application with Elastic APM but i can't see any log.
My application using .Net Framework 4.6.1 and i'm using Elastic.Apm.AspNetFullFramework Version 1.22.0

In Web.Config

<?xml version="1.0" encoding="utf-8"?>
<system.diagnostics>
	<sources>
		<source name="Elastic.Apm">
			<listeners>
				<add name="file" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\\logs\\APM_DEV.log" />
			</listeners>
		</source>
	</sources>
</system.diagnostics>
<system.web>
	<sessionState timeout="15" />
	<httpRuntime targetFramework="4.6.1" requestValidationMode="4.0" maxRequestLength="10485760" executionTimeout="300" requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,:,\,?" />
	<httpCookies httpOnlyCookies="true" requireSSL="true" sameSite="Strict" />
	<!-- 10 mb limit -->
	<pages controlRenderingCompatibilityVersion="4.0" validateRequest="true">
		<controls>
			<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
		</controls>
	</pages>
	
	<compilation debug="true" targetFramework="4.6.1" />
</system.web>
<appSettings>
	<add key="aspnet:MaxHttpCollectionKeys" value="10000" />
	<add key="log4net.Config" value="log4net.config" />

	<!-- For Elastic Integration -->
	<add key="ElasticApm:Enabled" value="true" />
	<add key="ElasticApm:ServerUrl" value="****" />
	<add key="ElasticApm:SecretToken" value="****" />
	<add key="ElasticApm:ServiceName" value="****" />
	<add key="ElasticApm:Environment" value="DEV" />
	<add key="ElasticApm:ApplicationNamespaces" value="" />
	<add key="ElasticApm:GlobalLabels" value="****" />
	<add key="ElasticApm:TransactionSampleRate" value="0.1" />
	<add key="ElasticApm:LogLevel" value="Trace" />
	<add key="ElasticApm:FlushInterval" value="0" />
	<!-- Elastic Integration -->
</appSettings>
<runtime>
	<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
		
		<dependentAssembly>
			<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-2.0.15.0" newVersion="2.0.15.0" />
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
			<!--<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />-->
		</dependentAssembly>
		<dependentAssembly>
			<assemblyIdentity name="System.Threading.Tasks.Dataflow" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
			<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
		</dependentAssembly>
	</assemblyBinding>
</runtime>

Kindly advice.

Hi @yasserzaid. You appear to be missing the registration of the ElasticApmModule for this to work. Note that .NET 4.6.1 is out of support, and older .NET Framework versions have some quirks, so we recommend using .NET 4.7.2+ for best results.

Here is my web.config

<system.webServer>
	<modules>
		<add name="ElasticApmModule" type="Elastic.Apm.AspNetFullFramework.ElasticApmModule, Elastic.Apm.AspNetFullFramework" preCondition="managedHandler" />
	</modules>
</system.webServer>

Did I miss something?

Can you please advice?

That configuration looks correct. Is the issue that you see no logs, no traces, or both?

For logging, you will need to ensure that the IIS AppPool Identify has permission to write to your configured directory D:\logs\APM_DEV.log.

Which version of IIS are you using?

Note: We don't support old .NET Framework versions which our out of support by Microsoft. You should upgrade to a supported runtime, ideally, .NET 4.7.2 or newer.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.