Closed JasonAtDrumBrae closed 1 year ago
namespace TestMicrosoftExtensions { using Microsoft.Extensions.Logging; using NUnit.Framework;
/// <summary>
/// The setup fixture.
/// </summary>
[SetUpFixture]
public class SetUpFixture
{
/// <summary>
/// The test suite log.
/// </summary>
private readonly ILogger<SetUpFixture> m_clsLog =
PLoggerFactory.CreateLogger<SetUpFixture>();
/// <summary>
/// Initializes static members of the <see cref="SetUpFixture" /> class.
/// </summary>
static SetUpFixture()
{
PLoggerFactory = LoggerFactory.Create(
clsBuilder => clsBuilder.AddLog4Net(@".\Logging\Log4Net.config")
.SetMinimumLevel(LogLevel.Debug));
}
/// <summary>
/// Gets the Logger Factory instance.
/// </summary>
public static ILoggerFactory PLoggerFactory { get; }
/// <summary>
/// The fixture setup.
/// </summary>
[OneTimeSetUp]
public void OneTimeSetUp()
{
m_clsLog.LogInformation("OneTimeSetUp()");
}
/// <summary>
/// The fixture tear down.
/// </summary>
[OneTimeTearDown]
public void OneTimeTearDown()
{
m_clsLog.LogInformation("OneTimeTearDown()");
}
}
}
Hello @JasonNewellAtAllegro.
This repository is not specific in how to use log4net outside Microsoft.Extensions.Logging system. Maybe I didn't understand you well, but I think that you should open same question in the log4net repository instead here.
I'm going to close this one. Sorry for inconveniences.
I believe its possible to use this purely as a façade for logging, so no Startup class or JSON config. Just a Program.cs or in NUnit3, SetUp.cs. How would we create a LoggerFactory instance with the Log4Net.confog file at a non default location?