# APM dotnet core agent - disable logging

**URL:** <https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [November 6, 2023, 4:27pm UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542 "2023-11-06T16:27:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shlomys](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shlomys/32/127274_2.png) [@shlomys](https://discuss.elastic.co/u/shlomys)\
**Post date:** [November 6, 2023, 4:27pm UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/1 "2023-11-06T16:27:29Z")

</div>

Hi,  
I am using elastic apm Elastic.Apm.NetCoreAll version 1.25.0.  
Tried every possible way to disable the logs:

```auto
ElasticApm:LogLevel=None
Logging:LogLevel:Elastic.Apm=None
environment variable ....

```

Nothing seems to work for me. Logs are still coming, for example:

```auto
2023-11-06 15:54:59.637 [INF] [1] {"ConfigurationStore"} Elastic APM .NET Agent, version: 1.25.0+ede1fffffc8b82780f30a35cd4cebf394afdcf8d
...
2023-11-06 15:54:59.599 [DBG] [1] {"AbstractConfigurationReader (ApmConfiguration)"} GlobalLabels configuration option doesn't have a valid value - using default (empty map)
...

```

Should these be affected by the above logging configuration?

Will appreciate if someone can support me on that.

Thanks.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [November 6, 2023, 5:33pm UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/2 "2023-11-06T17:33:43Z")

</div>

Hi @shlomys

Just to be precise....

Per the [docs](https://www.elastic.co/guide/en/apm/agent/dotnet/current/config-supportability.html#config-log-level) The Environment Variable Setting would be

`ELASTIC_APM_LOG_LEVEL`

And config per [here](https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net-core.html#sample-config)

```auto
{
  "Logging": {
    "LogLevel": { 
      "Default": "Warning",
      "Elastic.Apm": "None"
    }
  },

```

---

<div class="post-metadata">

**Author:** ![shlomys](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shlomys/32/127274_2.png) [@shlomys](https://discuss.elastic.co/u/shlomys)\
**Post date:** [November 7, 2023, 6:35am UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/3 "2023-11-07T06:35:58Z")

</div>

> [@stephenb](#):
>
> ELASTIC\_APM\_LOG\_LEVEL

I tried it as well, doesn't work, I still get log messages.  
One thing that may be related is that we use Serilog, but I am not sure if it's related.  
I found similar topic at [https://discuss.elastic.co/t/dotnet-6-0-log-level-setting/315258/2](https://discuss.elastic.co/t/dotnet-6-0-log-level-setting/315258/2) and tried to upgrade my apm library but it doesn't seem to resolve the issue.

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [November 7, 2023, 8:46am UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/4 "2023-11-07T08:46:58Z")

</div>

Hey, @shlomys.

The default log level if unconfigured is `Error`, yet you have `Debug` logs showing up too, so something is causing it to be configured at that level. It may depend on your use of Serilog.

Can you share the exact code portions for your app configuration setup (are you using `IConfguration`?), how you have configured Serilog, and how you registered the agent? That will help us understand the context better.

---

<div class="post-metadata">

**Author:** ![shlomys](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shlomys/32/127274_2.png) [@shlomys](https://discuss.elastic.co/u/shlomys)\
**Post date:** [November 7, 2023, 10:21am UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/5 "2023-11-07T10:21:38Z")

</div>

> [@stephenb](#):
>
> ```auto
> "Logging": {
> "LogLevel": { 
> "Default": "Warning",
> "Elastic.Apm": "None"
> }
> },
> 
> ```

Hi, found the issue. With Serilog the settings should be similar to the following:

"Serilog": {  
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.File"],  
"MinimumLevel": {  
"Default": "Debug",  
"Override": {  
"System": "Information",  
"Microsoft": "Information",  
"Microsoft.AspNetCore.Mvc.Infrastructure": "Warning",  
**"Elastic.Apm": "Fatal"**  
}  
},

The minimum Serilog level is Fatal which works for me (couldn't find 'None' for Serilog).

So now I have no Debug logs anymore, as expected. Suggest to add this to the documentation.

Many thanks everyone for the support.

---

<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:** [December 5, 2023, 10:22am UTC](https://discuss.elastic.co/t/apm-dotnet-core-agent-disable-logging/346542/6 "2023-12-05T10:22:14Z")

</div>

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