0

I am working on Dynamics AX 2012 r3, and I am debugging a batch job using Visual Studio 2013. In the Dynamics AX debugger, I can see the infolog messages in the infolog panel.

Is there a similar panel or way to view infolog messages when debugging in Visual Studio?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
2ps
  • 15,099
  • 2
  • 27
  • 47

1 Answers1

0

For what purposes? I could be wrong, but I'm thinking no without customization.

You can just add code in \Classes\Info\add to do whatever you want as a workaround. If you're attaching VS to AX, then System.Console::WriteLine("This might appear in the VS Output window"); may work. See code snip at end of this post.

This has some good options to explore: http://dev.goshoom.net/en/2012/05/console-output-ax/

You may be able to just open both debuggers, and when an infolog comes in, it might appear in the AX Debugger.

Add the below to your Info class and then put a call to it in the add() method and you'll be able to review the event viewer for infologs if you just need to see what's output. This was my workaround for debugging batch jobs or things in the CIL that were difficult to track.

static server void writeToSystemEventLog(str _message, Exception _exception = Exception::Info, int _eventId = 0)
{
    #define.logSource('Dynamics Ax')
    #define.logName('Dynamics Ax Log')
    System.Diagnostics.EventLog             eventLog;
    System.Diagnostics.EventLogEntryType    entryType;

    switch (_exception)
    {
        case Exception::Error:
            entryType = System.Diagnostics.EventLogEntryType::Error;
            break;

        case Exception::Warning:
            entryType = System.Diagnostics.EventLogEntryType::Warning;
            break;

        default:
            entryType = System.Diagnostics.EventLogEntryType::Information;
            break;
    }

    if (!System.Diagnostics.EventLog::SourceExists(#logSource))
    {
        System.Diagnostics.EventLog::CreateEventSource(#logSource, #logName);
    }

    eventlog = new System.Diagnostics.EventLog();
    eventLog.set_Source(#logSource);
    eventlog.WriteEntry(_message, entryType, _eventId);
}

The call:

static void Job99(Args _args)
{
    info::writeToSystemEventLog("Alex Test", Exception::Info, 1);
}

Then in the event viewer:

enter image description here

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71