Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging framework on Xamarin iOS

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?

like image 969
Adam Avatar asked Jun 29 '13 05:06

Adam


People also ask

Is Xamarin good for iOS?

The framework from Microsoft fully supports 64-mode and allows for using native tools directly and thus provides the fastest user interface. Xamarin developers can run the fastest code on both Android and iOS platforms.

Is Xamarin getting deprecated?

In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new . Net based product called MAUI - Multiform App User Interface.

What is Xamarin iOS framework?

Xamarin. Forms is an open source cross-platform framework from Microsoft for building iOS, Android, & Windows apps with . NET from a single shared codebase. Use Xamarin. Forms built in pages, layouts, and controls to build and design mobile apps from a single API that is highly extensible.

Where are the Xamarin logs?

Another option is to view the debug log via the command line. Open a Terminal window and navigate to the Android SDK platform-tools folder (typically, the SDK platform-tools folder is located at /Users/username/Library/Developer/Xamarin/android-sdk-macosx/platform-tools).


4 Answers

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

like image 61
Stephane Delcroix Avatar answered Oct 08 '22 23:10

Stephane Delcroix


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

like image 39
loop Avatar answered Oct 08 '22 23:10

loop


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

like image 41
drunkirishcoder Avatar answered Oct 08 '22 23:10

drunkirishcoder


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

like image 41
crittercismrob Avatar answered Oct 09 '22 01:10

crittercismrob