Multiply times the same output in visual studio console

Whenever i write some test messages to the console by using System.Diagnostics.Debug.Writeline("testmessage") I have the problem that the message is shown multiple times. I don't know why but maybe this happens because of the internal android console?!?? I am working with Xamarin in Visual Studio and develop an Android app.
1 answer

Preventing multiply output lines in Xamarin for Visual Studio on Android developement

I have used an very easy solution for this problem.
Whenever I need to do some output to the console (hint: you should only do this for you own purpose, later on you should Logging with respective logging levels in you app!) I do it the following way:

In the "App" class i have created a new method called "WriteLine" and there I use a dependency service call to execute some native java code on the android device:

public static void WriteLine(String line)
{
DependencyService.Get().WriteLine(line);
}

If you need help for using the DependencyService please look into further tutorials on that!
In the Implementation of the interface IOutput you just need the following code:

public void WriteLine(string line)
{
Console.WriteLine(line);
}

Like this you use the java "Console" class and you get the output at least one time less.

Taggings: