logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pelton, Brian" <bpel...@jgboswell.com>
Subject RE: Log4Net and MSTest
Date Fri, 10 Oct 2008 16:16:18 GMT
Actually it is working!  But the file isn't where I thought it would be
(in the TestResults\out folder)


It was actually written to:


C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\log4net.log



So the working directory is not the "out" directory as I had assumed.
Okay, well at least it is working!





From: Pelton, Brian [mailto:bpelton@jgboswell.com] 
Sent: Friday, October 10, 2008 9:06 AM
To: log4net-user@logging.apache.org
Subject: Log4Net and MSTest


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