-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
416 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Sample/ReflectInsight.Extensions.Log4Net.Sample/App.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight" /> | ||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | ||
</configSections> | ||
|
||
<!-- Logging Configuration | ||
Please make sure you update the Insight.config file property 'Copy to Output Directory' to 'Copy always'. | ||
For more information on ReflectInsight and configuration help, visit http://reflectsoftware.com. --> | ||
<insightSettings externalConfigSource="ReflectInsight.config" /> | ||
|
||
<log4net debug="false"> | ||
<appender name="MyLogAppender1" type="ReflectSoftware.Insight.Extensions.Log4net.LogAppender, ReflectSoftware.Insight.Extensions.Log4net"> | ||
<param name="InstanceName" value="log4netInstance1" /> | ||
<param name="DisplayLevel" value="true" /> | ||
<param name="DisplayLocation" value="true" /> | ||
</appender> | ||
|
||
<root> | ||
<appender-ref ref="MyLogAppender1" /> | ||
</root> | ||
</log4net> | ||
|
||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="ReflectSoftware.Insight" publicKeyToken="c78ddbdaf1f32b08" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-5.7.0.1705" newVersion="5.7.0.1705" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
53 changes: 53 additions & 0 deletions
53
Sample/ReflectInsight.Extensions.Log4Net.Sample/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
using log4net; | ||
|
||
// log4net stuff | ||
[assembly: log4net.Config.XmlConfigurator(Watch = true)] | ||
|
||
namespace Log4net_Sample | ||
{ | ||
class Program | ||
{ | ||
static void TestLog4net() | ||
{ | ||
ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
|
||
while (true) | ||
{ | ||
Console.WriteLine("Press any key or 'q' to quit..."); | ||
ConsoleKeyInfo k = Console.ReadKey(); | ||
if (k.KeyChar == 'q') | ||
{ | ||
break; | ||
} | ||
|
||
Exception ex = new Exception("This is my test exception!"); | ||
|
||
log.Info("[Enter]EnterMessage"); | ||
log.Info("My Info"); | ||
log.Info("My Info", ex); | ||
|
||
log.Debug("My Debug"); | ||
log.Debug("My Debug", ex); | ||
|
||
log.Warn("My Warn"); | ||
log.Warn("My Warn", ex); | ||
|
||
log.Error("My Error"); | ||
log.Error("My Error", ex); | ||
|
||
log.Fatal("My Fatal"); | ||
log.Fatal("My Fatal", ex); | ||
log.Info("[Exit]ExitMessage"); | ||
} | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
TestLog4net(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Sample/ReflectInsight.Extensions.Log4Net.Sample/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Log4net_Sample")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("764293de-1570-4d3a-864d-6911d415e220")] |
82 changes: 82 additions & 0 deletions
82
Sample/ReflectInsight.Extensions.Log4Net.Sample/README.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Log4net Extension Sample | ||
|
||
This sample demonstrates how to use the ReflectInsight Log4net Extension. The purpose of this sample is to show you how to leverage ReflectInsight with an pre-existing logging framework. | ||
|
||
This sample also uses satellite configuration files, which are a practice that we recommend doing. For more information about satellite configuration files, please | ||
see the satellite configuration sample and/or our online resource. | ||
|
||
To get started with the Log4net Extension, please do the following: | ||
|
||
1. Start by adding an application configuration file (app.config) to your project. If you already have one, then proceed to step #2. | ||
|
||
2. Next add/update the configSections with a section for for "insightSettings": | ||
|
||
<configSections> | ||
<section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight"/> | ||
</configSections> | ||
|
||
3. Then add a new section called <insightSettings></insightSettings> and add the externalConfigSource to point to your external ReflectInsight.config file: | ||
|
||
<insightSettings externalConfigSource="ReflectInsight.config" /> | ||
|
||
4. Please make sure you update the ReflectInsight.config file property 'Copy to Output Directory' to 'Copy always'. | ||
|
||
5. Next ensure you have configured you application with the applicable log4net configuration. | ||
|
||
6. In your log4net configuration, add a new appender for the ReflectInsight Log4net extension: | ||
|
||
<appender name="MyLogAppender1" type="ReflectSoftware.Insight.Extensions.Log4net.LogAppender, ReflectSoftware.Insight.Extensions.Log4net"> | ||
<param name="InstanceName" value="log4netInstance1" /> | ||
<param name="DisplayLevel" value="true" /> | ||
<param name="DisplayLocation" value="true" /> | ||
</appender> | ||
|
||
7. Now update your log4net configuration <root> section with a reference to the ReflectInsight Log4net appender you just added in step #6. | ||
|
||
<root> | ||
<appender-ref ref="MyLogAppender1" /> | ||
</root> | ||
|
||
8. Finally, you will need to configure the ReflectInsight.config file to hookup to the log4net appender. The following is the ReflectInsight.config file | ||
configuration. The section that I would like to highlight is the <logManager> and <instance>. Notice that the instance being used | ||
is the same name as the log4net appender. | ||
|
||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<insightSettings> | ||
<baseSettings> | ||
<configChange enabled="true" /> | ||
<propagateException enabled="false" /> | ||
<exceptionEventTracker time="20" /> | ||
<debugMessageProcess enabled="true" /> | ||
</baseSettings> | ||
|
||
<listenerGroups active="Debug"> | ||
<group name="Debug" enabled="true" maskIdentities="false"> | ||
<destinations> | ||
<destination name="Viewer" enabled="true" filter="" details="Viewer" /> | ||
</destinations> | ||
</group> | ||
</listenerGroups> | ||
|
||
<logManager> | ||
<instance name="log4netInstance1" category="Log4net1" /> | ||
</logManager> | ||
</insightSettings> | ||
</configuration> | ||
|
||
9. That's it your done! | ||
|
||
Additional Resources | ||
|
||
Getting started with the Log4net configuration | ||
https://insightextensions.codeplex.com/wikipage?title=Getting%20Started%20with%20Log4net%20Extension&referringTitle=Documentation | ||
|
||
Knowledge Base | ||
http://reflectsoftware.uservoice.com/knowledgebase | ||
|
||
User Feedback | ||
http://reflectsoftware.uservoice.com/forums/158277-reflectinsight-feedback | ||
|
||
Support | ||
support@reflectsoftware.com |
Oops, something went wrong.