Skip to content

GetCompressedLogs- how to for xamarin.forms project? #117

Description

@EmilAlipiev

Hi,

I am trying to implement attachments on crashes using metrolog. There is this blog post written but either it doesnt work i dont understand the exact implementation. https://devblogs.microsoft.com/appcenter/give-your-crashes-a-context-through-logs-attachments/
Basically in the post title with "App Center Brings Logs and Crash Together
The Idea".

I tried to implement this on xamarin.forms project. I am not sure code given there is for .net standard code or platform specific. However I tried both even using a DI to android project and get the manager and memorystream from there but still doesnt work. I dont see any attachment for my testcrash. Is there a better information regarding this how can make it work zip attachment in xamarin.forms projects?
my code would like as below,
in android project

 class LogManager :  Helpers.ILogManager
    {
        public MetroLog.ILogManager GetLogManager()
        {
            // Initialize MetroLog using the defaults
            LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new StreamingFileTarget());
            return LogManagerFactory.DefaultLogManager;
        }

        public  System.IO.MemoryStream GetCompressedLogs()
        {
            var _logManager = GetLogManager();
            System.IO.Stream compressedLogs = null;
            Task.Run(async () => compressedLogs = await _logManager.GetCompressedLogs()).Wait();
            return (System.IO.MemoryStream)compressedLogs;
        }
    }

In the shared standard project

 public static System.IO.MemoryStream GetCompressedLogs()
        {
            return Xamarin.Forms.DependencyService.Get<ILogManager>().GetCompressedLogs();
        }

Would this work? Do i understand things correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions