Skip to content

Commit

Permalink
Added Log4Net support for all demo apps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Jul 24, 2018
1 parent 9d57fdd commit edd6de6
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/AvalonDock.MVVMTestApp/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
http://yourlog4netviewer.codeplex.com/
-->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="${TMP}\MVVMTestApp_Log.log4j" />
<file type="log4net.Util.PatternString" value="${TMP}\AvalonDock.MVVMTestApp_Log.log4j" />
<!-- threshold value="DEBUG" / -->
<appendToFile value="false" />
<datePattern value="yyyyMMdd" />
Expand Down
39 changes: 39 additions & 0 deletions source/AvalonDock.TestApp/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!-- Setup Description: http://stackoverflow.com/questions/8138072/log4net-file-appender-not-logging -->
<!-- Ouput log information in XML readable format for Log4Net XML LogViewer (Open Source From Codeplex
http://yourlog4netviewer.codeplex.com/
-->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="${TMP}\AvalonDock.TestApp_Log.log4j" />
<!-- threshold value="DEBUG" / -->
<appendToFile value="false" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<!-- threshold value="WARN" / -->
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[Header]\r\n" />
<param name="Footer" value="[Footer]\r\n" />
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>

<root>
<!-- Levels: Off, Fatal, Error, Warn, Info, Debug, All -->
<level value="All" />
<appender-ref ref="RollingFileAppender" />
<!-- appender-ref ref="ConsoleAppender"/ -->
</root>
</log4net>

</configuration>
9 changes: 8 additions & 1 deletion source/AvalonDock.TestApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This program is provided to you under the terms of the New BSD
using System.Windows.Interop;
using System.Windows.Input;
using System.Diagnostics;
using log4net.Config;
using log4net;

namespace AvalonDock.TestApp
{
Expand All @@ -31,8 +33,13 @@ namespace AvalonDock.TestApp
/// </summary>
public partial class App : Application
{
public App()
protected static ILog Logger; // Enable debugging via Log4Net

static App()
{
XmlConfigurator.Configure(); // Read Log4Net config from App.config file
Logger = LogManager.GetLogger("default");

//Dispatcher.Thread.CurrentUICulture = new System.Globalization.CultureInfo("ru");
}
}
Expand Down
7 changes: 7 additions & 0 deletions source/AvalonDock.TestApp/AvalonDock.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net40-client\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand Down Expand Up @@ -140,6 +143,10 @@
<Name>Xceed.Wpf.AvalonDock</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 4 additions & 0 deletions source/AvalonDock.TestApp/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.8" targetFramework="net40-client" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net40-client\log4net.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down Expand Up @@ -99,6 +102,7 @@
<DependentUpon>FormMain.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
7 changes: 7 additions & 0 deletions source/AvalonDock.WinFormsTestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This program is provided to you under the terms of the New BSD
**********************************************************************/

using log4net;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -23,12 +25,17 @@ namespace AvalonDock.WinFormsTestApp
{
static class Program
{
private static ILog Logger; // Enable debugging via Log4Net

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
XmlConfigurator.Configure(); // Read Log4Net config from App.config file
Logger = LogManager.GetLogger("default");

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
Expand Down
33 changes: 33 additions & 0 deletions source/AvalonDock.WinFormsTestApp/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,40 @@
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="AvalonDock.WinFormsTestApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!-- Setup Description: http://stackoverflow.com/questions/8138072/log4net-file-appender-not-logging -->
<!-- Ouput log information in XML readable format for Log4Net XML LogViewer (Open Source From Codeplex
http://yourlog4netviewer.codeplex.com/
-->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="${TMP}\AvalonDock.WinFormsTestApp_Log.log4j" />
<!-- threshold value="DEBUG" / -->
<appendToFile value="false" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<!-- threshold value="WARN" / -->
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[Header]\r\n" />
<param name="Footer" value="[Footer]\r\n" />
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>

<root>
<!-- Levels: Off, Fatal, Error, Warn, Info, Debug, All -->
<level value="All" />
<appender-ref ref="RollingFileAppender" />
<!-- appender-ref ref="ConsoleAppender"/ -->
</root>
</log4net>
<userSettings>
<AvalonDock.WinFormsTestApp.Properties.Settings>
<setting name="DefaultLayout" serializeAs="String">
Expand Down
4 changes: 4 additions & 0 deletions source/AvalonDock.WinFormsTestApp/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.8" targetFramework="net40-client" />
</packages>

0 comments on commit edd6de6

Please sign in to comment.