cnblogs / EnyimMemcachedCore

.NET Memcached client. Available on https://www.nuget.org/packages/EnyimMemcachedCore
Apache License 2.0
162 stars 45 forks source link

Disable logging #140

Closed cesarbmx closed 4 years ago

cesarbmx commented 4 years ago

How can I avoid seeing the below trace in my log? I am using IDistributedCache with default configuration. I believed that, by default, the client was coming with logging disabled.

Memcached server address - xxxxx:11211
SetAsync("xxxxx")
GetAsync("xxxxx")
MemcachedInitPool-cost: 1182.8034ms
Enyim.Caching.Memcached.Protocol.Binary.GetOperation.ReadResponseAsync result: Not found
SetAsync("xxxxx")
MemcachedInitPool-cost: 1139.559ms
cnblogs-dudu commented 4 years ago

Change log level in appsettings.json.

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },

  "Serilog": {
    "MinimumLevel": {
      "Default": "Warning"
    }
  }
}
cesarbmx commented 4 years ago

Thank you.

I guess these memcached logs come asLogLevel: Information Since I am also logging Information from my application code, what you suggest would also hide my application related logs. Is there a way to hide Enyim specific logs while keeping LogLevel: Information in the appsettings?

cnblogs-dudu commented 4 years ago

Use the following log level settings.

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "Enyim.Caching": "Warning"
    }
  },

  "Serilog": {
    "MinimumLevel": {
      "Default": "Warning",
      "Override": {
        "Enyim.Caching": "Warning"
      }
    }
  }
}
cesarbmx commented 4 years ago

It worked! Thank you very much.