Console Logging

The Monobjc bridge provides a simple mean to do some advanced debugging, when something is going wrong in your application. As both managed and native libraries are involved in an application using the Monobjc bridge, it is important to known which side throws the error or does something strange.

The debugging activation is based on an environment variable named MONOBJC_LOG_LEVEL. The variable can be set to the following values :

  • error : This is the lowest level of debugging, which means that only errors will be printed out.
  • warn : This level will print out errors and warning.
  • info : This level will print out errors, warning and informationnal messages.
  • debug : Low-level log (class registration, proxy creation, messaging, etc.). Beware that this level will slow down the execution.

The debugging is done through these simple steps :

  • Open a Terminal console. The Terminal application is found in /Applications/Utilities folder.
  • Set the MONOBJC_LOG_LEVEL environment variable (see above). The command is typically export MONOBJC_LOG_LEVEL=x where x is the desired level.
  • Launch the application by its command line. To launch a Cocoa application, type ./APPNAME.app/Contents/MacOS/APPNAME where APPNAME is the name of your application.

The results will be lines of log that can help you to diagnose what is going wrong in the application.

Others Debugging Facilities

It is possible to use the environment variables listed in the Mac OS X Debugging Magic technical note. Some of them are very useful, like NSZombie: it is used to identify messages sent to deallocated instances.