This I don't Is the purpose of the form- I,e guidance on a speciifc issue is different from online training and consulting, and you probably should speak to a consulting company Ax developer because any answer ahs to start with some assumptions e,.g that you know how to write and compile code etc. You also have to consider which messages to capture and for how long and with what other details e.g date and employee id. Running as a batch also gives you the option of looking at batch history - SysOperation framework).
First consider how to manually save a message:.
Right-click on the heading of the Infolog and you get a pop-up context menu that lets you copy the Infolog messages to the clipboard – then go into Notepad or Word (or Excel if there are lots of messages, because that makes it slightly easier to filter the rows), and paste.
The other drop down menu option 'Copy as list to Clipboard’ collapses the message parent-child structure into single lines
So automate that process is an approach. Anyway here are two options.,(
To capture infolog messages for a particular record and show those logs on click of a log button on a form.
1) Create a job which inserts records into a table, prints some info messages and capture those messages.
logTable contains three fields EmpId, name and info. info is a field created with EDT infologData and visible property is set to NO.
info is a container which stores the infolog messages for the particular record.
static void logs(Args _args)
{
logTable insertLog;
NumberSeq numberSeq;
InfologData msg;
ttsbegin;
insertLog.initValue();
numberSeq = NumberSeq::newGetNum(InventParameters::numRefEmpID());
insertLog.EmpId = numberSeq.num();
insertLog.Name = 'ABC';
info(strFmt("%1", insertLog.EmpId));
info(strFmt("%1", insertLog.Name));
info(strFmt("Employee with %1 & name %2 created successfully", insertLog.EmpId,insertLog.Name));
msg = infolog.infologData();
insertLog.Info = msg;
insertlog.insert();
infolog.clear();
ttscommit;
}
NOTEWS :
i) Save compile and run this job. EmpId is generated through number sequence and name is hard coded. These two values are inserted into table.
ii) The info stored for this record are :
EMPID-0001
New
Employee with EMPID-0001 & name ABC created successfully
2) Now create a form with grid showing the logTable datasource fields and button named log.
Write the following code in clicked method of the button
void clicked()
{
InfologData msg;
msg = logTable.info;
infolog.import(msg);
}
Now when you select this particular record and press the log button the infolog messages stored for this record are displayed in info.
You can otherwise save the infolog content to the Windows Event Log or to a file on disk. This can be done in 2012 with the help of listeners. read more on this, at https://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener%28v=vs.110%29.aspx.
Edit your Ax32.exe.config file (or if this file doesn't exist near the Ax32.exe app file, then create it) and append this code snippet:
<configuration>
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="Microsoft.Dynamics.Kernel.Client.DiagnosticLog-Infolog"
switchValue="Information">
<listeners>
<add name="EventLog"
type="System.Diagnostics.EventLogTraceListener"
initializeData="Dynamics Trace Infolog"/>
<add name="TextFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="DynamicsTraceInfologTrace.log"
traceOutputOptions="DateTime"/>
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
I'm done.