I'm using MvvmCross. In the library I see usage of Mvx.Trace method, but no output to the console/output window. How to use it?
p.s. I have set the compiler constant Trace = true
Thanks.
I'm using MvvmCross. In the library I see usage of Mvx.Trace method, but no output to the console/output window. How to use it?
p.s. I have set the compiler constant Trace = true
Thanks.
MvvmCross DebugTrace is all routed via a singleton implementation of
IMvxTrace
Each platform provides different implementations of this:
Debug
trace (becauseTrace
itself is not available on all the Windows platforms)Debug
and the Androidlog
Debug
and the iOSConsole
This worked well in earlier versions of MvvmCross, especially where people linked directly to the MvvmCross source code and so could bind directly to either the debug or release MvvmCross binaries.
However... because people are now increasingly using the release Binaries from Nuget - in which
Debug
is of course compiled out, then this often leaves people asking "How to use it?"The easiest way is for you to override the initialisation of IMvxTrace in your
Setup
class.This is easy to do - e.g.:
where
MyDebugTrace
is something like:If you wanted to include different implementations for debug/release; if you wanted to switch this on/off at runtime; if you wanted to filter on
MvxTraceLevel
ortag
; or if you wanted to use some third party logging engine then this should also be easy to do using simple C# on each platform.Just hitting an issue on iOS with the current solution provided by Stuart.
Running a debug session in VS with the MvxTrace using
Debug.WriteLine
can be extremely slow depending on how verbose is your app logging. Same forTrace.WriteLinte
. UseConsole.WriteLine
instead (as MvvmCrossMvxDebugTrace
does) which is not impacted.See this Xamarin bug item for "more" details: https://bugzilla.xamarin.com/show_bug.cgi?id=13538#c4