Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specflow BeforeTestRun Logging

[BeforeFeature]
public static void BeforeFeature()
{

    featureTitle = $"{FeatureContext.Current.FeatureInfo.Title}";
    featureRollFileAppender = new RollingFileAppender
    {
        AppendToFile = true,
        StaticLogFileName = true,
        Threshold = Level.All,
        Name = "FeatureAppender",
        File = "test.log",
        Layout = new PatternLayout("%date %m%newline%exception"),
    };
    featureRollFileAppender.ActivateOptions();
    log.Info("test");

}

I am attempting to use log4net to output a simple string, however, once the file has been generated, it does not contain any data. No errors are thrown and the test does complete successfully.

like image 504
Roo Avatar asked Apr 20 '26 12:04

Roo


1 Answers

It turns out that the previously selected RollingFileAppender was still open and I needed to select another RollingFileAppender. This is one of the issues when using multiple log files. Once this was resolved, the Info() method would output to my desired log file.

I was able to resolve my issue by adding the following code:

        BasicConfigurator.Configure(nameRunRollFileAppender);
        log = LogManager.GetLogger(typeof(Tracer));
        log.Info("Output some data");
like image 108
Roo Avatar answered Apr 22 '26 01:04

Roo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!