Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7716835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:43:53+00:00 2026-06-01T02:43:53+00:00

I am using NUnit to test a project and I’d like to configure my

  • 0

I am using NUnit to test a project and I’d like to configure my tests to setup Common.Logging programmatically to use Log4Net. Here’s what I’ve tried:

        NameValueCollection config = new NameValueCollection();
        //config.Add("configType", "EXTERNAL");

        var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DevelopMENTALMadness.Data.Sql.Tests.loggerconfig.xml");
        XmlConfigurator.Configure(stream);

        LogManager.Adapter = new Log4NetLoggerFactoryAdapter(config);

With the following file:

<log4net>
<appender name="A1" type="log4net.Appender.ConsoleAppender">

    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[%thread] %-4timestamp %-5level %logger %ndc - %message%newline" />
    </layout>
</appender>

<!-- Set root logger level to DEBUG and its only appender to A1 -->
<root>
    <level value="DEBUG" />
    <appender-ref ref="A1" />
</root>

And

        NameValueCollection config = new NameValueCollection();
        //config.Add("configType", "EXTERNAL");

        var x = new ConsoleAppender { Layout = new PatternLayout("[%thread] %-4timestamp %-5level %logger %ndc - %message%newline") };
        BasicConfigurator.Configure(x);

        LogManager.Adapter = new Log4NetLoggerFactoryAdapter(config);

But either it doesn’t use the pattern I specify or if I uncomment the “configType” line it displays nothing at all. I’m just trying to select the layout I want so when I’m debugging my tests I can see the log output in the NUnit runner (Text Output).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:43:55+00:00Added an answer on June 1, 2026 at 2:43 am

    So here’s what I ended up doing – it meets my goal of wanting to see the output in NUnit runner console, plus I ended up adding a rolling file logger as well.

    In the test class:

    [TestFixtureSetUp]
    public void Init()
    {
        BasicConfigurator.Configure(new ConsoleAppender());
    }
    

    Then I have an App.config file (copy always):

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="common">
                <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
            </sectionGroup>
            <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
        </configSections>
    
        <common>
            <logging>
                <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
                    <arg key="configType" value="INLINE"/>
                </factoryAdapter>
            </logging>
        </common>
    
        <log4net debug="false">
            <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
                <file value="./Tests.log" />
                <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
                <appendToFile value="true" />
                <rollingStyle value="Size" />
                <maxSizeRollBackups value="10" />
                <maximumFileSize value="50MB" />
                <staticLogFileName value="true" />
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
                </layout>
                <threshold value="DEBUG" />
            </appender>
            <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
                </layout>
            </appender>
            <root>
                <priority value="ALL"/>
                <appender-ref ref="RollingFileAppender"/>
                <appender-ref ref="ConsoleAppender" />
            </root>
        </log4net>
    </configuration>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had set up a bunch of NUnit unit tests using the Test connection
I usually use Nunit but in my current project I am using MSTest. Now
When using NUnit and the test project, we haven't been able to find a
I am trying to test a class in Service handler using NUnit project. My
I'm using NUnit for my unit tests and I have my unit test class
I'm setting up a MSBuild project to run some NUnit test, using the MSBuild
I'm using nUnit to test the routing of my MVC2 project. When I register
When I create new NUnit unit tests in my test project, the ReSharper Unit
My team makes extensive use of NUnit unit tests in our C# project. Recently
I am using NUnit asserts within a MSTest project like as follows ( NOTE:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.