logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pelton, Brian" <bpel...@jgboswell.com>
Subject Log4Net and MSTest
Date Fri, 10 Oct 2008 16:05:46 GMT
Does anyone use MSTest and if so, have you had success in getting
logging to work with your tests?


Normally, in my application log4net is configured by a call to:



But, I'm writing tests for one of my library projects, so I don't see a
good place to put such a statement.


I thought I would try using the assembly attribute and an app.config
file to configure log4net, but this doesn't seem to work.


In a file called "Logging.cs" I have this;


using log4net.Config;

[assembly: XmlConfigurator()]



And my app.config looks like this:


<?xml version="1.0" encoding="utf-8" ?>



    <sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >

      <section name="SNIP.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />


    <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />




      <setting name="DefaultEnvironmentPath" serializeAs="String">



      <setting name="ConfigurationFilename" serializeAs="String">



      <setting name="Log4NetConfigurationFilename" serializeAs="String">






    <appender name="DetailedAppender"
type="log4net.Appender.FileAppender, log4net">

      <file type="log4net.Util.PatternString" value="log4net.log" />

      <appendToFile value="false" />

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%date %-5level %logger -
%message%newline" />




      <level value="INFO" />

      <appender-ref ref="DetailedAppender" />


    <logger name="NHibernate">

      <level value="WARN" />







Brian Pelton

J.G. Boswell Company



View raw message