What is the exact way we can print logs using log4net and specflow with .net 6.0

58 Views Asked by At

I want to print logs to separate file in my existing project which created using Specflow with .NET 6.0.

Can someone explain to me how it needs to be done?

I have tried the below steps but not worked.

Added this dependency:

<PackageReference Include="log4net" Version="2.0.15" />

And this project does not have the app.config or log4net.config (I manually created log4net.config) and passed configs

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    </configSections>

    <log4net>
        <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date %level %message%newline" />
            </layout>
        </appender>
        <root>
            <level value="ALL" />
            <appender-ref ref="ConsoleAppender" />
        </root>
    </log4net>
</configuration>

Also in this project, I cannot see AssemblyInfo.cs or Program.cs file or main method.

I have used the [BeforeTestRun] tag to initiate some reports, If need I can use this space if I need to call any method

0

There are 0 best solutions below