Usually it will be difficult to monitor/debug Batch Jobs running on server . For e.g if something goes wrong than we can't find out why.
So we can make use of Eventviewer instead of infolog and monitor the status by checking the eventviewr .
Following Job illustrates how to write to event viewer.
static void Dev_Write2EventViewer(Args _args)
{
System.Diagnostics.EventLog eventlog;
Str logSource;
Str logName;
;
logSource = "Dynamics Ax";
logName = "Dynamics Ax Log";
// check if the log already exists
if(!System.Diagnostics.EventLog::SourceExists(logSource))
{
// create new log
System.Diagnostics.EventLog::CreateEventSource(logSource, logName);
}
eventlog = new System.Diagnostics.EventLog();
eventlog.set_Source(logSource);
eventlog.WriteEntry("Info Message");
eventlog.WriteEntry("Warning Message" , System.Diagnostics.EventLogEntryType::Warning);
eventlog.WriteEntry("Error! Please check the stack trace below. \n\n" +
con2str(xSession::xppCallStack()), System.Diagnostics.EventLogEntryType::Error);
info("Check the event viewer!");
}
Enjoy ....!!!! Batch Jobs...
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.