Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there append mode? #44

Open
VinShen opened this issue Jun 7, 2024 · 6 comments
Open

Is there append mode? #44

VinShen opened this issue Jun 7, 2024 · 6 comments

Comments

@VinShen
Copy link

VinShen commented Jun 7, 2024

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

@roubachof
Copy link
Owner

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

@VinShen
Copy link
Author

VinShen commented Jun 7, 2024

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()
.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
Copy link
Author

VinShen commented Jun 7, 2024

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

@roubachof
Copy link
Owner

Just delete the folder

@VinShen
Copy link
Author

VinShen commented Jun 9, 2024

@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

@roubachof
Copy link
Owner

Dude you are literally quoting the folder you need to delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants