Is there append mode?
The log works fine when App is active. Properly displayed.
When App is closed (or crashed) , a new log is created on opening the App again. Is there Append mode in the logger so that previous log automatically get saved. If above is possible, is there way to clear the log.
Thanks
If you use stream file all logs will be retained for a specific duration (option). Then use the share button or the get compressed logs to get the zipped logs
Thanks @roubachof
I am testing Log on Android 14 with Maui App with MetroLog.Maui nuget 2.1.0
I did all the things mentioned in ReadMe for Maui configuration
public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder.UseMauiApp<App>() .ConfigureFonts( fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); });
builder.Logging
.AddTraceLogger(
options =>
{
options.MinLevel = LogLevel.Trace;
options.MaxLevel = LogLevel.Critical;
}) // Will write to the Debug Output
.AddInMemoryLogger(
options =>
{
options.MaxLines = 1024;
options.MinLevel = LogLevel.Debug;
options.MaxLevel = LogLevel.Critical;
})
.AddStreamingFileLogger(
options =>
{
options.RetainDays = 2;
options.FolderPath = Path.Combine(
FileSystem.CacheDirectory,
"MetroLogs");
});
builder.Services.AddSingleton(LogOperatorRetriever.Instance);
builder.Services.AddSingleton<MainPage>();
return builder.Build();
}
}
In App constructor LogController.InitializeNavigation(page => MainPage!.Navigation.PushModalAsync(page), () => MainPage!.Navigation.PopModalAsync());
I could view, share log as zip everything works fine, but for that instance of App. When App is closed (or crashed), a new log is created on opening the App again.
Am I missing something?
OK. I got it.
Though it is not displayed on screen, it is appended in file and I can see it when I download it. Thanks @roubachof
One small question. How can I clear the log, without clearing App Cache?
Thanks
Just delete the folder
@roubachof
If I am using
.AddStreamingFileLogger( options => { options.RetainDays = 2; options.FolderPath = Path.Combine(FileSystem.CacheDirectory, "MetroLogs"); });
Which folder I have to delete from Android Device? Thanks
Dude you are literally quoting the folder you need to delete