-
Notifications
You must be signed in to change notification settings - Fork 359
Configure Logging
By default the client comes with logging disabled (uses a NullLogger which does nothing), and supports log4net and NLog.
<configuration>
<configSections>
<sectionGroup name="enyim.com">
<section name="log" type="Enyim.Caching.Configuration.LoggerSection, Enyim.Caching" />
</sectionGroup>
</configSections>
<enyim.com>
<log factory="fully qualified type name" />
</enyim.com>
</configuration>
You need to declare (see the sectionGroup
) and add the enyim.com/log
element. The factory tells the client which logger to use.
You need to reference the Enyim.Caching.Log4NetAdapter.dll
assembly. (Make sure you reference log4net as well.)
If you're using configuration files you need to declare it in your app.config:
<enyim.com>
<log factory="Enyim.Caching.Log4NetFactory, Enyim.Caching.Log4NetAdapter" />
</enyim.com>
Alternatively, you can define your logger from code:
using Enyim.Caching;
LogManager.AssignFactory(new Log4NetFactory());
You need to reference the Enyim.Cachin.NLogAdapter.dll
assembly. (NLog is not included in the binary distribution of the client.)
If you're using configuration files you need to declare it in your app.config:
<enyim.com>
<log factory="Enyim.Caching.NLogFactory, Enyim.Caching.NLogAdapter" />
</enyim.com>
Alternatively, you can define your logger from code:
using Enyim.Caching;
LogManager.AssignFactory(new NLogFactory());
The package includes a basic diagnostics logger which dumps every log message sent by the client (DEBUG verbosity). It's recommended to only enable this logger if you do not use log4net or NLog and you need to figure out why the client fails. Do not use it in production because it seriously impacts the performance.
If you're using configuration files you need to declare it in your app.config:
<enyim.com>
<log factory="Enyim.Caching.DiagnosticsLogFactory, Enyim.Caching" />
</enyim.com>
You also need to specify the log path:
<appSettings>
<add key="Enyim.Caching.Diagnostics.LogPath" value="file path" />
</appSettings>
Code:
using Enyim.Caching;
LogManager.AssignFactory(new DiagnosticsLogFactory("path to the log file"));
If you use other logging methods you can still make the client to support them.
Implement the Enyim.Caching.ILog and the Enyim.Caching.ILogFactory interfaces, then either add it to the config file or use the LogManager to register it.