Bug 24021 - MONO_LOG_LEVEL and MONO_LOG_MASK not working for GC message logging
Summary: MONO_LOG_LEVEL and MONO_LOG_MASK not working for GC message logging
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 8.2.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2014-10-23 15:59 UTC by John Miller [MSFT]
Modified: 2014-11-28 07:50 UTC (History)
7 users (show)

Tags:
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:
Status:
VERIFIED FIXED

Description John Miller [MSFT] 2014-10-23 15:59:41 UTC
**Overview:**

   Setting these values in XS or via additional mtouch arguments are causing the app to show GC logging messages as described here: http://developer.xamarin.com/guides/ios/advanced_topics/environment/

**Steps to Reproduce:**

   1. Set MONO_LOG_LEVEL to debug and MONO_LOG_MASK to gc in the iOS project options -> Run -> General. 
   2. Enable the Sgen collector in the iOS build -> advanced tab.
   3. Launch from XS in debug mode

**Actual Results:**

   No GC messages are displayed in.

**Expected Results:**

   GC log messages in the Application Output window. 

**Build Date & Platform:**

   XI 8.4.0.15
   XS 5.6.2 and tried XS 5.5.2
   Mono 3.10
Comment 1 Rajneesh Kumar 2014-10-27 09:08:34 UTC
I have checked this issue and able to reproduce the reported behavior "MONO_LOG_LEVEL and MONO_LOG_MASK not working for GC message logging". To reproduce this issue I have followed the steps mentioned in bug description.

Steps I followed:

1. Create an iOS application in XS
2. Right click iOS project=>options -> Run -> General
3. Set MONO_LOG_LEVEL to debug and MONO_LOG_MASK to gc
4. Go to iOS build -> advanced tab and enable the Sgen collector
5. Launch from XS in debug mode
6. Observe that No GC messages are displayed in Output window.

Screencast: http://www.screencast.com/t/gNWi1Uzg

Please confirm that It is same issue that you have reported and also confirm whether I have followed correct steps to reproduce this issue or not?

Please let me know if I am missing anything.

Environment Info: 

=== Xamarin Studio ===

Version 5.5.2 (build 3)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.10.0 ((detached/e204655)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000023

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===

Version: 8.4.0.15 (Business Edition)
Hash: 08968c4
Branch: 
Build date: 2014-10-20 21:48:06-0400

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: /Users/MM/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)
		4.4.87 (API level 20)
		4.5    (API level 21)
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)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 505020003
Git revision: 6d4c806e383ba366b15fbccca9ddc1ba94f8d5ad
Build date: 2014-10-15 15:00:36-04
Xamarin addins: 069ddd29bb70a42238142eee9bac21a5e4b2f9f9

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Rob Ringham 2014-10-27 09:11:44 UTC
> Please confirm that It is same issue that you have reported and also confirm
whether I have followed correct steps to reproduce this issue or not?

Confirmed on both points - this is the issue I'm observing, and those are the correct steps to reproduce it.
Comment 3 Rajneesh Kumar 2014-10-27 09:19:19 UTC
As per comment 2 confirmation of same issue "Confirmed on both points - this is the issue I'm observing, and those are the correct steps to reproduce it." Changing its status needinfo to confirmed.
Comment 4 Sebastien Pouliot 2014-11-07 16:55:21 UTC
Has anyone checked if the output was in the device console logs ? 

Nothing in the referenced document states this will go back to XS Application Output.
Comment 5 John Miller [MSFT] 2014-11-07 17:37:03 UTC
I do not see any messages in the console logs.
Comment 6 Sebastien Pouliot 2014-11-11 11:38:19 UTC
XS launch logs shows the options are given to the process

> Launching /private/var/mobile/Applications/5FE85CE5-88BB-49AB-BED6-886B5C35136B/b23089u.app -monodevelop-port 10000 -connection-mode usb -setenv:MONO_LOG_LEVEL=debug -setenv:MONO_LOG_MASK=gc

Adding those in FinishedLaunching

	Console.WriteLine ("GC: {0} {1}", GC.MaxGeneration == 0 ? "Boehm": "sgen", NSObject.IsNewRefcountEnabled () ? "+ NewRefCount" : String.Empty);
	Console.WriteLine ("MONO_LOG_LEVEL {0}", Environment.GetEnvironmentVariable ("MONO_LOG_LEVEL"));
	Console.WriteLine ("MONO_LOG_MASK {0}", Environment.GetEnvironmentVariable ("MONO_LOG_MASK"));

shows

> 2014-11-11 11:17:34.428 b24021[5794:60b] GC: sgen + NewRefCount
> 2014-11-11 11:17:35.378 b24021[5794:60b] MONO_LOG_LEVEL debug
> 2014-11-11 11:17:36.258 b24021[5794:60b] MONO_LOG_MASK gc

so the variables are present at execution time.

OTOH nothing seems to each the device console logs. It could be disabled (form the runtime) or sent to something that does not reach ASL.

c.c. Rodrigo wrt Mono logging
Comment 7 Sebastien Pouliot 2014-11-11 11:46:25 UTC
--enable-minimal=ssa,com,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,perfcounters,attach,verifier,full_messages,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting \

logging ?

If that's it then enabling this might have a negative impact on the final application sizes.

We might want to move toward having release/debug libmono [1] but that will affect build times.

[1] https://trello.com/c/wfDwt53H/8-ship-both-release-and-debug-runtimes
Comment 8 Rodrigo Kumpera 2014-11-11 12:02:28 UTC
Logging disables JIT logging, not the runtime one.

The fact that the env vars are been set doesn't say it all. It must be set before the runtime is initialized as those are read only during initialization.

This is the code that is used for logging. It's been in use quite some time:
https://github.com/mono/mono/blob/master/eglib/src/goutput.c#L179
Comment 9 Rolf Bjarne Kvinge [MSFT] 2014-11-12 09:25:43 UTC
The GC logging ends up being sent to asl_log with level = ASL_LEVEL_INFO, which is usually not shown anywhere.
Comment 10 Rodrigo Kumpera 2014-11-12 09:38:57 UTC
Rolf, my suggestion is that you guys implement the new logging API instead of patching mono.
Comment 11 Rolf Bjarne Kvinge [MSFT] 2014-11-12 09:45:36 UTC
Rodrigo, that's what I did.

maccore/master: bdd4f092bc2040bdad604845fedb8a641405b065
monotouch/master: 11ac1565a1457358dfe7bc25be7308c74039fd8a
xamcore/master: 11ac1565a1457358dfe7bc25be7308c74039fd8a
Comment 12 Rodrigo Kumpera 2014-11-12 09:47:22 UTC
Awesome awesome awesome :) :) :)
Comment 13 Danish Akhtar 2014-11-28 07:50:12 UTC
Today, I have checked this issue with:
XS 5.7(build 596)- d996e9ba6874a0d64241e43e5e6b06322ce29c84
X.iOS 8.6.0.5
OSX 10.8.5

Now, this issue doesn't exists, I have followed the steps mentioned in bug descreption and observed that we are getting 'GC Message in application output of XS'.
 
Here is the screenacst for the same: http://www.screencast.com/t/J7F2dhcOPG11

Hence closing this issue.