ZiggyCreatures / FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
MIT License
1.91k stars 97 forks source link

[QUESTION] Correct way to disable logging #135

Closed sherman89 closed 1 year ago

sherman89 commented 1 year ago

I'm currently using FusionCache as a simple memory cache, and I don't need any logging and would rather get that performance boost instead. Factory exceptions are already handled on application level so it's also unnecessary as far as I see?

What is the correct way to disable logging? Would it be this?

services.AddMemoryCache();
var fusionCacheBuilder = services.AddFusionCache().WithRegisteredMemoryCache();
fusionCacheBuilder.UseRegisteredLogger = false;

Thanks!

jodydonetti commented 1 year ago

Hi @sherman89 , and thanks for using FusionCache!

For a lot of components I created a WithoutXyz() method to specify you want to go "withOUT" it... but not for the logger it seems 🤷. My Bad, will add it in the next release.

Meanwhile you can simply use WithLogger(...) and pass an instance of NullLogger<T>.

Hope this helps, let me know.

sherman89 commented 1 year ago

Thanks @jodydonetti I did it this way now:

services.AddFusionCache()
    .WithRegisteredMemoryCache()
    .WithLogger(NullLogger<FusionCache>.Instance);

Seems to work fine 🙂

I guess I can close this issue now

jodydonetti commented 1 year ago

Great, happy it worked!

Anyway I'm still adding a WithoutLogger() in the next release, so to have a better dev exp with in a more explicit and less clunky way.

Will update you as soon as it will be available.

jodydonetti commented 1 year ago

Hi @sherman89 , I'm tracking the development here.

jodydonetti commented 1 year ago

Hello @sherman89 , v0.21.0-preview1 is out, which includes the new WithoutLogger() method.

sherman89 commented 1 year ago

@jodydonetti Thank you! Will start using it as soon as possible :)

jodydonetti commented 1 year ago

Hi, v0.21.0-preview2 is out: one more week of baking and the official v0.21.0 will be released 🎉

jodydonetti commented 1 year ago

Hi all, I just release v0.21.0 which includes this 🎉