Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example project with configuration files #11

Open
adrian-herscu opened this issue Apr 12, 2022 · 1 comment
Open

example project with configuration files #11

adrian-herscu opened this issue Apr 12, 2022 · 1 comment

Comments

@adrian-herscu
Copy link

Trying to work with configuration files with no success...
Getting this error message:

slf4net: The factory resolver AppConfigFactoryResolver returned null from GetProvider().  The fallback no operation logger factory will be used instead.

Have no clue what's wrong! I have an App.config file in the root directory of the project with following contents:

<configuration>

    <configSections>
        <section name="slf4net" type="slf4net.Configuration.SlfConfigurationSection, slf4net"/>
    </configSections>

    <slf4net>
        <factory type="slf4net.log4net.Log4netLoggerFactory, slf4net.log4net">
            <factory-data>
                <configFile value="log4net.config"/>
            </factory-data>
        </factory>
    </slf4net>

</configuration>

and a log4net.config with:

<log4net debug="false">
    <appender name="Console" type="log4net.Appender.ConsoleAppender">
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date %-5level: %message%newline" />
        </layout>
    </appender>

    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="Log.txt" />
        <appendToFile value="false" />
        <rollingStyle value="Size" />
        <maxSizeRollBackups value="10" />
        <maximumFileSize value="50MB" />
        <staticLogFileName value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%-5level: %message%newline" />
        </layout>
    </appender>

    <root>
        <level value="INFO" />
        <appender-ref ref="Console" />
        <appender-ref ref="RollingFileAppender" />
    </root>
</log4net>
@adrian-herscu-philips
Copy link

Added to .csproj

<Project Sdk="Microsoft.NET.Sdk">
  <Target Name="CopyConfigurationFiles" AfterTargets="AfterBuild">
    <Copy SourceFiles="log4net.config" DestinationFiles="$(OutDir)\log4net.config" />
    <Copy SourceFiles="App.config" DestinationFiles="$(OutDir)\App.config" />
    <Copy SourceFiles="App.config" DestinationFiles="$(OutDir)\testhost.x86.dll.config" />
  </Target>

Followed:
nunit/nunit3-vs-adapter#17
https://stackoverflow.com/questions/55541912/using-an-app-config-file-with-nunit3-in-a-net-core-console-app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants