Logging framework on Xamarin iOS

11,728

Solution 1

Logging on iOS is a bit different than logging on a desktop/server application, as the user has no (easy) way to retrieve the logs.

There are multiple options though:

  1. For your own debugging purposes:

    use System.Console.WriteLine(). That's equivalent to Obj-C NSLog

  2. For remote logging:

    use a third party framework e.g.

    • TestFlight SDK (for beta testing, but there's a private beta for production builds as well)

    • Crashlytics

    Some solutions even provide remote logging, so you can have access to crash reports and device logs.

    It goes without saying that you can use most of these frameworks from Xamarin.iOS, check https://github.com/mono/monotouch-bindings

Solution 2

I think you can use Xamarin Insights for logging. Xamarin Insights

Solution 3

I forked Apache log4net and made it compile under MonoTouch with some essential appenders. Expect bugs since it's not fully tested, but it's a start.

monotouch-log4net @ GitHub

Solution 4

Crittercism just released an official crash reporting and logging framework for Xamarin (Full disclosure: I'm one of the co-founders). It has full support for automatically logging unhandled exceptions and signals (signals like SIGSEGV are handled gracefully by letting the Mono runtime handle them and pass the full stacktrace to Crittercism). You can also send any logs to Crittercism as well using handled exception logging. You can download it from the Xamarin store here:

http://components.xamarin.com/view/crittercism

Share:
11,728
Adam
Author by

Adam

Updated on July 10, 2022

Comments

  • Adam
    Adam almost 2 years

    What's the state of logging on Xamarin.iOS (using Xamarin Studio Indie).

    I've tried using NLog, but it references System.ServiceModel - so Xamarin complains that I need business edition (not paying that much just to use NLog!)

    log4net also doesn't work, because it references classes in System.Configuration that don't exist in Xamarin/MonoTouch.

    I find it surprising that there isn't a logging solution available, either in with XS, or by the major logging players.

    What am missing?

  • Jakub Bielan
    Jakub Bielan about 9 years
  • Jakub Bielan
    Jakub Bielan about 9 years
    For remote logging Xamarin Insights is good option: developer.xamarin.com/guides/cross-platform/insights/…