Difference between revisions of "Common Logging"
From Hiasobi - FHIR
Brett Esler (Talk | contribs) (→Common Logging) |
Brett Esler (Talk | contribs) |
||
Line 29: | Line 29: | ||
</common> | </common> | ||
</configuration> | </configuration> | ||
+ | </code> | ||
+ | |||
+ | == NLog Typical Configuration == | ||
+ | The typical logging location for Hiasobi. | ||
+ | |||
+ | |||
+ | <code> | ||
+ | <?xml version="1.0" encoding="utf-8" ?> | ||
+ | <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | ||
+ | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
+ | |||
+ | <targets> | ||
+ | <target xsi:type="File" name="userlog" layout="${longdate} ${logger} ${message} ${exception:Message,StackTrace}" fileName="${specialfolder:ApplicationData}/<adapter name>/logs/log.today.txt" archiveFileName="${specialfolder:ApplicationData}/TelstraRunner/logs/log.{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" concurrentWrites="true" /> | ||
+ | <target xsi:type="Console" name="console" /> | ||
+ | </targets> | ||
+ | |||
+ | <rules> | ||
+ | <logger name="*" minlevel="Trace" writeTo="userlog" /> | ||
+ | </rules> | ||
+ | </nlog> | ||
</code> | </code> |
Revision as of 11:20, 29 July 2016
Common Logging
Supported as follows:
- Common.Logging.dll (v2.1.1.0) built in
- External adapters e.g. NLog - Common.Logging.NLog20.dll
- Configuration: <app>.exe.config - configure logging
- Default is no logging (null logger)
NLog Configuration
Require libraries and configuration
- Common.Logging.NLog20.dll - NLog2 common logging adapter
- NLog.dll - NLog2 core library
- NLog.config - external configuration file for NLog; (may be done in-line in the <app>.exe.config)
- <app>.exe.config - inject dependency and reference NLog.cofig external file
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> </sectionGroup> </configSections> <common> <logging> <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20"> <arg key="configType" value="FILE" /> <arg key="configFile" value="NLog.config" /> </factoryAdapter> </logging> </common> </configuration>
NLog Typical Configuration
The typical logging location for Hiasobi.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets> <target xsi:type="File" name="userlog" layout="${longdate} ${logger} ${message} ${exception:Message,StackTrace}" fileName="${specialfolder:ApplicationData}/<adapter name>/logs/log.today.txt" archiveFileName="${specialfolder:ApplicationData}/TelstraRunner/logs/log.{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" concurrentWrites="true" /> <target xsi:type="Console" name="console" /> </targets>
<rules> <logger name="*" minlevel="Trace" writeTo="userlog" /> </rules>
</nlog>