This is a submodule to provide a File Logging Provider to be used with .NET Microsoft.Extensions.Logging.
Because the term of "Tripous" used in reference who wasn't not my cup of thea then to enhence little things but it should be a fork.
Execute in command line to your project's root:
git submodule add https://github.com/mabyre/FileLogger.Logging.git
var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging =>
{
//logging.ClearProviders();
logging.AddFileLogger();
//logging.AddFileLogger(options => {
// options.MaxFileSizeInMB = 5;
//});
})
.Build();
public partial class MainWindow : Window
{
private readonly ILogger<MainWindow> _logger;
private readonly ILoggerFactory _loggerFactory;
public MainWindow(ILoggerFactory loggerFactory)
{
InitializeComponent();
public partial class YourUserControl : UserControl
{
private ILogger<YourUserControl> logger;
public YourUserControl(ILoggerFactory loggerFactory)
{
InitializeComponent();
// In xaml there is some text in Text so add a NexLine
textBoxLog.Text += Environment.NewLine;
logger = loggerFactory.CreateLogger<YourUserControl>();
logger.LogWarning("My UserControl getting initialized");
}
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Trace",
"Microsoft.Hosting.Lifetime": "Trace"
},
"File": {
"LogLevel": "Trace",
"Folder": ".\\Logs"
},
Project using this module in a WPF Application:
https://github.com/mabyre/WpfAppCore1
This module used in Blazor Server Application