Why does Debug.WriteLine output appear twice?

EasyGoingPatEasyGoingPat GBMember ✭✭✭
edited March 2016 in Visual Studio

Hi,

I am encountering an issue that I am sure was not happening a few weeks ago.

If I put Debug.WriteLine( "Test message" ); in an iOS AppDelegate, the output in Visual Studio is as follows:

2016-03-17 19:54:29.406 MyAppiOS[13506:495498] Test message
[0:] Test message

Sometimes there is a newline between the two entries (as shown above) and sometimes they occur on the same line.

This is also true no matter where I put the calls, including in my PCL for the application.

I'd be grateful if someone else would give this a quick test (you will need to add using System.Diagnostics to the top of your file), to see if you get the same result.

I guess it is not the end of the world, but it is really annoying when you don't understand why something is happening (and it often disguises a more serious problem).

Kind wishes ~ Patrick

Best Answer

Answers

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    I've been seeing the same and wondering why. Never bothered me enough to find out why though - but it would be interesting to know.

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    It's not a show-stopper, but it makes logs a lot more difficult to read. I use an excellent filtering program for text files, but it struggles because of the killer that sometimes the lines have newlines between them and sometimes they don't.

    Thanks for the answer though. It's good to know you are not alone. :-)

  • JohnHindJohnHind GBMember ✭✭
    edited May 2016

    Hm ... I'm using Console.WriteLine in an Android app and my output appears twice too:

    Console.WriteLine("My Message");

    generates:

    My Message
    05-20 16:10:52.610 I/mono-stdout(22994): My Message

    Patrick is right - write a nice formatted dump of a hierarchical structure and this totally screws up the readability!

  • JeffreyVoigtJeffreyVoigt USMember
    edited May 2016

    I have 3 lines using System.Diagnostics.Debugger.Writeline()... Running a forms app output to the VS android emulator:

    5/25/2016 1:47:09 PM stopped
    [0:] 5/25/2016 1:47:09 PM stopped
    05-25 13:47:09.268 I/mono-stdout( 1552): 5/25/2016 1:47:09 PM stopped

    How can I make it stop!??

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @JeffreyVoigt @JohnHind

    I settled on using Console.Writeline(), at least in iOS, but to do this, I had to inject it using the DependencyService. This got rid of the duplicate lines, but unfortunately had an equally annoying bug: some output lines are arbitrarily cut into two by a newline character.

    I have just noticed I have switched back to Debug.Writeline() in the Windows Phone project. Can't remember why. And I haven't actually set this up in Android yet, as I have only just started work on that platform.

    If you come up with anything that works, I'd love to hear it.

    • Patrick
Sign In or Register to comment.