Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF and log4net troubles when Debug Info not Full.

$
0
0

I had posted a problem here tfs 2013 build issues with log4net

They suggested I post here as after further investigation it does seem to be a WPF issue.

I am using Visual Studio 2013, .net framework 4.5, log4net.dll (Version 1.2.13)

If you create a WPF application and reference log4net.dll and make the App.xaml.cs like this

using System.Windows;
using log4net;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace wpfdemo
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private static readonly ILog _log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        protected override void OnStartup(StartupEventArgs e)
        {
            _log.Error("WPF Test Error");
        }
    }
}

and change the App.config to be

<?xml version="1.0" encoding="utf-8" ?><configuration><startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup><configSections><section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/></configSections><runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="DataAnnotationsExtensions" publicKeyToken="358a5681c50fd84c" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-1.0.1.0" newVersion="1.0.1.0" /></dependentAssembly></assemblyBinding></runtime><log4net><appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" ><applicationName value="testlog4net" /><layout type="log4net.Layout.PatternLayout,log4net"><conversionpattern value="%property{EnvironmentName} :: %property{AppVersion} :: %property{log4net:HostName} :: %username :: %level :: %message %newlineLogger: %logger%newlineThread: %thread%newlineDate: %date%newline" /></layout></appender><root><level value="ERROR" /><appender-ref ref="EventLogAppender" /></root></log4net></configuration>
and then execute the application in Debug, then the error is logged in the event log, if you then execute using the Release Configuration where Debug Info is pdb-only the error will not be logged.


Simon


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>