|
List Info
Thread: Configuration of Log4net with Visual Studio 2008 unit testing
|
|
| Configuration of Log4net with Visual
Studio 2008 unit testing |
  United Kingdom |
2008-05-16 10:18:54 |
|
Does anyone know how to use log4net.config files with Visual
Studio 2008 unit testing?
I have a test project with a log4net.config file as part of the
project, properties set to Content and Copy always, which diligently copies the
config file to the binrelease or bindebug folders on build. In the
test class the [ClassInitialize] method includes this line:
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config"));
which should point log4net to the executable folder for the test
project, I thought. However the tests cannot find the config file: the
log4net internal logging produces this message:
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [log4net.config] watching for file
updates
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [log4net.config]
log4net: XmlConfigurator: config file [C:Documents and
SettingsNeilMy DocumentsVisual Studio
2008ProjectsMatrixRootMatrix5TestResultsNeil_DEVNH 2008-05-16
15_50_22Outlog4net.config] not found. Configuration unchanged.
It seems to be looking for
…TestResultsNeil_DEVNH 2008-05-16 15_50_22Outlog4net.config
but I do not understand why. Well, I do understand, but
the trouble is that this folder is a moving target and I don’t understand how
to configure it to look in a stationary directory such as binrelease.
Can anyone help with this puzzle?
TIA
|
| RE: Configuration of Log4net with Visual
Studio 2008 unit testing |
  United Kingdom |
2008-05-16 10:36:08 |
|
Okay – got it. All I needed to do in the test class was specify
a relative path from the test project output to the folder where my common config
file is located within the solution..
eg
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo( "......ProjectBeingTestedlog4net.config"));
and it uses the same file regardless of where the test output is
being generated.
Thanks to anyone who started looking into this!
From: Neil Haughton
[mailto:Neil.Haughton autoscribe.co.uk]
Sent: 16 May 2008 16:19
To: Log4NET User
Subject: Configuration of Log4net with Visual Studio 2008 unit testing
Does anyone know how to use log4net.config files with Visual
Studio 2008 unit testing?
I have a test project with a log4net.config file as part of the
project, properties set to Content and Copy always, which diligently copies the
config file to the binrelease or bindebug folders on build. In the test class
the [ClassInitialize] method includes this line:
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config"));
which should point log4net to the executable folder for the test
project, I thought. However the tests cannot find the config file: the
log4net internal logging produces this message:
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [log4net.config] watching for file
updates
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [log4net.config]
log4net: XmlConfigurator: config file [C:Documents and
SettingsNeilMy DocumentsVisual Studio
2008ProjectsMatrixRootMatrix5TestResultsNeil_DEVNH 2008-05-16 15_50_22Outlog4net.config]
not found. Configuration unchanged.
It seems to be looking for
…TestResultsNeil_DEVNH 2008-05-16 15_50_22Outlog4net.config
but I do not understand why. Well, I do understand, but the
trouble is that this folder is a moving target and I don’t understand how to
configure it to look in a stationary directory such as binrelease.
Can anyone help with this puzzle?
TIA
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|