Difference between revisions of "Common Logging"
From Hiasobi - FHIR
Brett Esler (Talk | contribs) |
Brett Esler (Talk | contribs) |
||
Line 12: | Line 12: | ||
* NLog.config - external configuration file for NLog; (may be done in-line in the <app>.exe.config) | * 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 | * <app>.exe.config - inject dependency and reference NLog.cofig external file | ||
+ | |||
<code> | <code> | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
Line 39: | Line 40: | ||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
− | |||
<targets> | <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="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" /> | <target xsi:type="Console" name="console" /> | ||
</targets> | </targets> | ||
− | |||
<rules> | <rules> | ||
<logger name="*" minlevel="Trace" writeTo="userlog" /> | <logger name="*" minlevel="Trace" writeTo="userlog" /> |
Revision as of 11:23, 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>