Bug 22144 - Logging format/behavior inconsistency between iOS and other targets.
Summary: Logging format/behavior inconsistency between iOS and other targets.
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.9.1.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-08-16 19:39 UTC by Brian Berry
Modified: 2014-08-22 15:07 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brian Berry 2014-08-16 19:39:29 UTC
Observed: Inconsistency in Console.WriteLine() output between

Steps to reproduce:
  * Make simple apps for each platform.
  * Perform some simple logging with Console.WriteLine. 

  * Xamarin.Android/Xamarin.Mac log to the application output
    without any prefixing, whereas Xamarin.iOS output with
    the device/NSLog-style prefixing, e.g.:

2014-08-16 14:10:20.798 MyApp[1530:1331688] 2014-08-16 21:10:20.7979 MyText

  * Consistent behavior across platforms.

  * This is a very minor issue, but has required me to fork some custom logging
    code for the platforms to deal with the fact that one is the odd man out.
    E.g., adding my own date/timestamp for the other platforms results in
    duplication on iOS, plus I have plans for logging consumers that I'd
    like to not have to specialize to remove the iOS-only prefixing.'
  * I'd also like to request that debug/release behaviors for output also
    be consistent.  Currently, X.Android and X.Mac both allow output in
    release.  I cannot verify this for iOS presently, as the current XS
    and X.iOS behavior on launch (in release only) is to detach immediately.
    As a result, currently, I have to chase down release-only temp logging
    in the Xcode device logs instead.  I will file the detachment issue

Version: (Indie Edition)
Hash: 1686c40
Build date: 2014-08-11 15:30:23-0400
Comment 1 Udham Singh 2014-08-18 13:48:11 UTC
I have checked this issue with the help of steps provided in bug and observed the same behaviour mentioned in bug description. Please refer the screencast : http://screencast.com/t/7IFjECTetP

Environment Info : 

=== Xamarin Studio ===

Version 5.2.1 (build 1)
Installation UUID: 952292e8-1484-4c56-b664-6ff701bef591
	Mono 3.6.0 ((no/f540f8a)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000039

=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 606f31a
Build date: 2014-08-01 15:27:48-0400

=== Build Information ===

Release ID: 502010001
Git revision: d06832ce9807d6be24aca225457e8b37c7669f6f
Build date: 2014-08-07 12:10:47-04
Xamarin addins: 1de032531be4cecf2f39dbee3b87aac78204058c

=== Operating System ===

Mac OS X 10.9.3
Darwin Xamarin76s-Mac-mini.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Comment 2 Sebastien Pouliot 2014-08-22 10:23:09 UTC
With iOS we are forced* to go thru NSLog (asl facilities) or the data won't be shown in the devices log. This layer adds the extra information you're seeing (so it's not iOS-like, it's really iOS). 

ASL does this to help distinguish the logs from different applications sharing its service.

Now this restriction was not enforced on the simulator (or on developer's devices) but having a different code path for them is more complex and dangerous as "not doing it like Apple says" always end up in more pain at some point.

* Apple changed this in iOS 5.1. That broke a lot of (existing) applications since all the 'printf'-like functions (to stdout/stderr) started to return access denied, which then thrown a UnauthorizedException (in managed code).
Comment 3 Brian Berry 2014-08-22 15:07:04 UTC
I certainly figured this was a result of needing to play nice with the OS for general logging support, and I completely understand that.  I was just thinking perhaps, in the case where you're attached to the debugger/XS, the output there could be made consistent.

Again, this is a very minor issue---I appreciate your comments, and will just continue to provide logging filters where we need.  (There is other out-of-band chatter evident in other targets, too, so a bit unavoidable.)