Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Configuration of Log4net with Visual Studio 2008 unit testing
Prev Next
You are not authorized to post a reply.

Author Messages
Neil Haughton

05/16/2008 5:18 PM  

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 bin\release or bin\debug 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 Settings\Neil\My Documents\Visual Studio 2008\Projects\MatrixRoot\Matrix5\TestResults\Neil_DEVNH 2008-05-16 15_50_22\Out\log4net.config] not found. Configuration unchanged.

 

It seems to be looking for

 

…\TestResults\Neil_DEVNH 2008-05-16 15_50_22\Out\log4net.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 \bin\release.

 

Can anyone help with this puzzle?

 

TIA

Neil Haughton

05/16/2008 5:36 PM  

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(@"..\..\..\ProjectBeingTested\log4net.config"));

 

and it uses the same file regardless of where the test output is being generated.

 

Thanks to anyone who started looking into this!

 

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Configuration of Log4net with Visual Studio 2008 unit testing



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement