15

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?

Adam
  • 4,159
  • 4
  • 32
  • 53

4 Answers4

13

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

Adam
  • 4,159
  • 4
  • 32
  • 53
Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • For remote logging Xamarin Insights is good option: http://developer.xamarin.com/guides/cross-platform/insights/application/#Logging_Reports_to_Xamarin_Insights – pauldendulk May 02 '15 at 07:03
6

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

loop
  • 9,002
  • 10
  • 40
  • 76
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

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105
2

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

crittercismrob
  • 419
  • 2
  • 8