# .Net Agent Instrumentation for IIS hosted app

**URL:** <https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [May 21, 2020, 5:38pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784 "2020-05-21T17:38:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 21, 2020, 5:38pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/1 "2020-05-21T17:38:23Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

**Kibana version** : 7.7

**Elasticsearch version** : 7.7

**APM Server version** : 1.5

**APM Agent language and version** : .Net ( Elastic.Apm.AspNetFullFramework)

**Browser version** :chorme

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: nuget

**Fresh install or upgraded from other version?**

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

**Steps to reproduce** :  
Hi Team ,

We are trying to instrument our .net app with Elastic APM .net agent .  
We have made following changes :

added below to web.config

\<system.webServer\>  
  
  
  
\</system.webServer\>

and

But the application is not reporting to controller .

We have validated connectivity and other basic stuff .

please help

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 21, 2020, 5:51pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/2 "2020-05-21T17:51:17Z")

</div>

Hi @joychatterjee05,

I'm not sure you pasted the whole `web.config` file as you intended - it seems to be empty.

Have you checked [this part](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup.html#setup-asp-net) of the docs?

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 21, 2020, 6:08pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/3 "2020-05-21T18:08:49Z")

</div>

not sure why it did not got pasted correctly at first.

![image](https://us1.discourse-cdn.com/elastic/original/3X/2/8/2895c30e14c1c99a217b375536ee4fb4bd6f8488.png)

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 21, 2020, 6:14pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/4 "2020-05-21T18:14:32Z")

</div>

Yes I referred same doc for instrumentation.

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 21, 2020, 6:22pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/5 "2020-05-21T18:22:39Z")

</div>

Ok, this looks good to me.

The next step would be to collect logs from the Agent - [here](https://www.elastic.co/guide/en/apm/agent/dotnet/master/troubleshooting.html#no-data-sent) we have details on how to do that. Can you maybe do that?

Once we have agent logs, we'll probably quickly see what's the issue based on the logs.

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 21, 2020, 6:56pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/6 "2020-05-21T18:56:01Z")

</div>

Hi Greg ,

Thank you for prompt reposnse.  
I see application is using log4net for logging , while the above solution seems to be for nlog.

Could you please suggest and alternative .

Regards  
Joy

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 21, 2020, 9:09pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/7 "2020-05-21T21:09:01Z")

</div>

@joychatterjee05 the solution described in the docs is general - all you need to do is to print your logs with log4net in the `public void Log<TState>(ApmLogLevel apmLogLevel, TState state, Exception e, Func<TState, Exception, string> formatter)` method. So it'd be almost identical to the linked nlog sample, except in the `Log` method you log with log4net

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 25, 2020, 6:18pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/8 "2020-05-25T18:18:15Z")

</div>

Hi Greg ,

We did not had an option to change application code to enable additional logging thus captured logs using DebigView , below is the error we captured .

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a22390322a189965cbe7335e73bffbb43e2f37e.png)  
Could you please advice .

Regards  
Joy

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 26, 2020, 10:46am UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/9 "2020-05-26T10:46:04Z")

</div>

Thanks for the log @joychatterjee05,

this seems to be an exception in our platform detection - very strange. Definitely not something we expected to happen.

I opened a GitHub issue for this: [https://github.com/elastic/apm-agent-dotnet/issues/859](https://github.com/elastic/apm-agent-dotnet/issues/859)

Could you maybe share me more info about this? Where is the app running? What .NET version, what IIS version - anything that you think could help me to debug this better?

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [May 26, 2020, 4:36pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/10 "2020-05-26T16:36:19Z")

</div>

Hello Greg ,

.NET Version is - 4.6.1  
IIS Version is - 10.0  
OS - Windows Server 2016

let me know if you need more information around this.

Regards  
Joy

---

<div class="post-metadata">

**Author:** ![joychatterjee05](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@joychatterjee05](https://discuss.elastic.co/u/joychatterjee05)\
**Post date:** [June 2, 2020, 3:26pm UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/11 "2020-06-02T15:26:16Z")

</div>

Hi Greg ,

Is there a way we can still instrument this application ?

Regards  
Joy

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [June 5, 2020, 11:09am UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/12 "2020-06-05T11:09:58Z")

</div>

Hi @joychatterjee05,

there was a very useful comment on the GitHub issue [here](https://github.com/elastic/apm-agent-dotnet/issues/859#issuecomment-639401183) - could you maybe check if that'd also solve your problem?

Also to address your question:

> Is there a way we can still instrument this application ?

I hope the GitHub suggestion solves your issue, otherwise unfortunately I don't think we can make it work in that environment with the latest release.

I already merged a fix to handle the error into `master` - we'll publish a nightly pre-release with that, once that's out we could give you that to test and see if that helps.

But the first step should be the binding redirect from the linked GitHub issue, because I think that'd already solve the issue for you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2020, 7:10am UTC](https://discuss.elastic.co/t/net-agent-instrumentation-for-iis-hosted-app/233784/13 "2020-06-26T07:10:05Z")

</div>

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