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!

 

--Brian

 

 

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:

   log4net.Config.XmlConfigurator.Configure(logConfigFile);

 

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" ?>

<configuration>

  <configSections>

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

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

    </sectionGroup>

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

  </configSections>

  <userSettings>

    <SNIP.Properties.Settings>

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

        <valueSNIP\env\unittest</value>

      </setting>

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

        <value>SNIP.config.xml</value>

      </setting>

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

        <value>log4net.config.xml</value>

      </setting>

    </SNIP.Properties.Settings>

  </userSettings>

  <log4net>

    <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" />

      </layout>

    </appender>

    <root>

      <level value="INFO" />

      <appender-ref ref="DetailedAppender" />

    </root>

    <logger name="NHibernate">

      <level value="WARN" />

    </logger>

  </log4net>

</configuration>

 

 

 

Brian Pelton

J.G. Boswell Company

bpelton@jgboswell.com

 


Mime
View raw message