-
Notifications
You must be signed in to change notification settings - Fork 0
Logging
ardliath edited this page Sep 11, 2014
·
5 revisions
Logging in the library is done with log4net.
To view the logs generated by the library configure an appender and record the namespaces below Liath.ViewRanger
Here's a sample application
static void Main(string[] args)
{
XmlConfigurator.Configure(); // configure log4net from the app.config
var appKey = @"123456789";
var username = "user1";
var pin = "1234";
var client = new ViewRangerClient(appKey);
var lastLocation = client.GetLastPosition()
.ForUser(username, pin)
.Request();
}The following configuration will write the logs to a text file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<!-- Log debug messages the client library -->
<logger name="Liath.ViewRanger">
<level value="Debug" />
</logger>
<root>
<!-- Log errors from our application -->
<level value="ERROR" />
<appender-ref ref="RollingFileAppender" />
</root>
</log4net>
</configuration>For more details see the log4net documentation.