This project has moved. For the latest updates, please go here.
SharpMap uses Common.Logging http://netcommon.sourceforge.net for logging purposes. This makes it possible to integrate sharpmap logging/tracing with other logging-frameworks such as log4Net and NLog.

For applications that does not provide any logging configuration no debug or trace messages will be output.

To get SharpMap to output log-information you could configure that with the app.config file

Configuration that outputs logging information to Console

This configuration tells SharpMap to trace all information to Console during execution.

You can change the log-level by changing from DEBUG to INFO, WARN, or ERROR to restrict logging only to important messages
  • DEBUG - Most information outputed, will make execution slower since some debug-information need to be calculated
  • INFO - Less information outputed, mostly informal messages about execution
  • WARN - Only warnings and Errors outputed
  • ERROR - Only error messages are outputed

<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
 </sectionGroup>
</configSections>
<common>
    <logging>
      <!--Log to Console_-->
      <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
        <arg key="level" value="DEBUG" />
        <arg key="showLogName" value="true" />
        <arg key="showDateTime" value="true" />
        <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
      </factoryAdapter>
    </logging>
  </common>

Log with Log4Net

For projects using Log4Net or NLog already it's an easy task to redirect SharpMap logging to those frameworks be adding a configuration like this

You need additional assemblies to be able to log to Log4Net or NLog, please see the Common.Logging web for information

Configure sections for Common.Logging and Log4Net
<configSections>
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
    <section name="log4net"
         type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>

Configure Common.Logging to log to Log4Net
<common>
    <logging>
      <!-- Log with Log4Net -->
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
        <arg key="configType" value="INLINE" />
      </factoryAdapter>
    </logging>
  </common>

Configure Log4Net to output ALL messages to a textfile called log.txt
<!-- configures log4net to write into a local file called "log.txt" -->
  <log4net>
    <appender name="MainAppender" type="log4net.Appender.FileAppender">
      <param name="File" value="log.txt" />
      <param name="AppendToFile" value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="MainAppender" />
    </root>
  </log4net>

Last edited Sep 27, 2013 at 9:40 AM by FObermaier, version 5