MetroLog icon indicating copy to clipboard operation
MetroLog copied to clipboard

Is there append mode?

Open VinShen opened this issue 1 year ago • 6 comments

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

VinShen avatar Jun 07 '24 14:06 VinShen

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

roubachof avatar Jun 07 '24 14:06 roubachof

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?

VinShen avatar Jun 07 '24 14:06 VinShen

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

VinShen avatar Jun 07 '24 14:06 VinShen

Just delete the folder

roubachof avatar Jun 07 '24 18:06 roubachof

@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

VinShen avatar Jun 09 '24 11:06 VinShen

Dude you are literally quoting the folder you need to delete

roubachof avatar Jun 09 '24 14:06 roubachof