0

As in the title, I am trying to debug my program by writing to the console in xamarin forms. I have tried System.Diagnostics.Debug.WriteLine and Console.WriteLine in multiple paces and neither of them has any output that I can see in the debug output or the device log.

Edit:

See no output in Visual Studio Debug output for the following code.

using CustomRenderer;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace CarpApp
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class MainPage : ContentPage
    {
        private static ILogger logger = DependencyService.Get<ILogManager>().GetLog();

        public MainPage()
        {
            InitializeComponent();
            logger.Trace("Test1");
            System.Diagnostics.Debug.WriteLine("Test2");
        }

        private void OnMessagesTapped(object sender, EventArgs args)
        {
            System.Diagnostics.Debug.WriteLine("Test3");
            Console.WriteLine("Test4");
            logger.Trace("Test5");
        }

        private void OnFindTapped(object sender, EventArgs args)
        {
            Navigation.PushAsync(new MapPage());
        }

        private void OnGetRidTapped(object sender, EventArgs args)
        {
            Navigation.PushAsync(new GetRidPage());
        }
    }

}

Canyonman133
  • 49
  • 11

2 Answers2

1

As as a workaround you can add NLog logging to your app (See This link for details). In addition to FileTarget logging, you can define a DebuggerTarget, which goes directly into the console.

Markus Michel
  • 2,289
  • 10
  • 18
  • 1
    Thanks for the response but this doesn't seem to have worked. I see no output to the console for the code I added to the original post. I am using Visual Studio and looking at the output from Debug. – Canyonman133 Jun 15 '18 at 00:04
  • I create the targets programatically: #if DEBUG LoggingRule debugrule = new LoggingRule("*", LogLevel.Trace, fileTarget); config.LoggingRules.Add(debugrule); LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, new DebuggerTarget()); config.LoggingRules.Add(rule2); #else LoggingRule loggingrule = new LoggingRule("*", LogLevel.Trace, fileTarget); config.LoggingRules.Add(loggingrule); LogManager.Configuration = config; – Markus Michel Jun 15 '18 at 09:17
0

I finally fixed the problem, the issue was that there were a bunch of screwed up namings throughout the project.

Canyonman133
  • 49
  • 11