Installation

The recommended method to install the adapter is through NuGet:

https://docs.nuget.org/docs/start-here/managing-nuget-packages-using-the-dialog

The package is called Common.Logging.Loupe

If you would like to use the binary directly you will need to obtain the following dependencies:

  1. Common.Logging (v ≥ 2.1.2) http://netcommon.sourceforge.net/
  2. Gibraltar Agent (v ≥3.5.6.1696) http://www.gibraltarsoftware.com/Loupe

 

We have issued several new versions of this package to maintain compatibility with different versions of Common.Logging.

1.3.1.x | Common.Logging 3.1+
1.3.0.x | Common.Logging 3.0
1.2.2.x | Common.Logging 2.2
1.2.1.x | Common.Logging 2.1

Usage

A detailed usage example is included in the Common.Logging.Loupe.Example project. The following is a simplified version:

Configuration

Configure the Gibraltar element in App.config using the following instructions/documentation: http://www.gibraltarsoftware.com/Support/Loupe/Documentation/WebFrame.html#DevelopersReference_AgentConfiguration_AppConfig.html

 

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="gibraltar">
<section name="listener" type="Gibraltar.Agent.ListenerElement, Gibraltar.Agent" />
<section name="packager" type="Gibraltar.Agent.PackagerElement, Gibraltar.Agent" />
<section name="publisher" type="Gibraltar.Agent.PublisherElement, Gibraltar.Agent" />
<section name="sessionFile" type="Gibraltar.Agent.SessionFileElement, Gibraltar.Agent" />
<section name="viewer" type="Gibraltar.Agent.ViewerElement, Gibraltar.Agent" />
<section name="email" type="Gibraltar.Agent.EmailElement, Gibraltar.Agent" />
<section name="server" type="Gibraltar.Agent.ServerElement, Gibraltar.Agent" />
<section name="autoSendConsent" type="Gibraltar.Agent.AutoSendConsentElement, Gibraltar.Agent" />
<section name="networkViewer" type="Gibraltar.Agent.NetworkViewerElement, Gibraltar.Agent" />
<section name="properties" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<gibraltar>
<!-- Here is where all of the Gibraltar configuration sections can be added. -->
</gibraltar>
<system.diagnostics>
<trace>
<listeners>
<add name="gibraltar" type="Gibraltar.Agent.LogListener, Gibraltar.Agent" />
</listeners>
</trace>
</system.diagnostics>
<common>
<logging>
<factoryAdapter type="Common.Logging.Loupe.LoupeFactoryAdapter, Common.Logging.Loupe">
<arg key="level" value="Trace" />
</factoryAdapter>
</logging>
</common>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Getting a Class Logger

The first step in writing to the log file is to obtain a logger for the current class.  This can be done through the static LogManager.GetCurrentClassLogger() method call:

var logger = LogManager.GetCurrentClassLogger();

This will obtain an implementation of ILog which exposes logging methods should as Error, Warning, and Info.  The full documentation for ILog can be found here:  Common Logging Usage

 

Ending a Session

Gibraltar logging relies on the concept of a log session.  When your application is exiting the session should end.  If you do not explicitly close the session Gibraltar will assume that the session has terminated unexpectedly.  

A session can be ended in the following ways:

  1. Directly through the Gibraltar.Log static class methods.
    Gibraltar.Agent.Log.EndSession("Session Finished");
  2. Through the Common.Logging.Loupe.LoupeLogUtility static class methods
    Common.Logging.Loupe.LoupeLogUtility.EndSessionNormally("Session Finished.");

For more information about session please see the integration section of the Loupe documentation:

http://www.gibraltarsoftware.com/Support/Loupe/Documentation/WebFrame.html#WPF_DevelopersReference_IntegrationCode.html

Last edited Aug 2, 2015 at 6:09 PM by ams3cf, version 6