Skip to content

Commit 81ddd14

Browse files
committed
log4net config moved to app.config
1 parent 63372d2 commit 81ddd14

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

Source/ManagedTest/App.config

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<configSections>
4+
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
5+
</configSections>
36
<system.diagnostics>
47
<trace autoflush="true" indentsize="0">
58
<listeners>
69
<add name="SysInternalsListener" type="Sysinternals.Debug.ProcessMonitorTraceListener, Sysinternals.Debug"/>
710
</listeners>
811
</trace>
912
</system.diagnostics>
10-
<startup>
11-
12-
<supportedRuntime version="v2.0.50727"/></startup>
13+
<log4net>
14+
<appender name="ProcMon" type="Sysinternals.log4net.ProcMonAppender, Sysinternals.log4net">
15+
<layout type="log4net.Layout.PatternLayout">
16+
<conversionPattern value="%-5level %message" />
17+
</layout>
18+
</appender>
19+
20+
<root>
21+
<level value="DEBUG" />
22+
<appender-ref ref="ProcMon" />
23+
</root>
24+
</log4net>
25+
1326
</configuration>

Source/ManagedTest/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ class Program
1616
{
1717
static void Main(string[] args)
1818
{
19+
/*
1920
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
2021
hierarchy.Root.AddAppender(new ColoredConsoleAppender());
2122
hierarchy.Root.AddAppender(new ProcMonAppender());
2223
hierarchy.Root.Level = Level.Debug;
2324
hierarchy.Configured = true;
24-
25+
*/
2526
ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
2627
Debug.Listeners.Remove("Default");
2728

Source/ManagedTest/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8+
using log4net.Config;
9+
810
[assembly: AssemblyTitle("ManagedTest")]
911
[assembly: AssemblyDescription("")]
1012
[assembly: AssemblyConfiguration("")]
@@ -34,3 +36,6 @@
3436
// [assembly: AssemblyVersion("1.0.*")]
3537
[assembly: AssemblyVersion("1.0.0.0")]
3638
[assembly: AssemblyFileVersion("1.0.0.0")]
39+
40+
// Read the log4net config from the app.config
41+
[assembly:XmlConfigurator(Watch = false)]

0 commit comments

Comments
 (0)