How to log into Event Viewer

maheshmahesh Member Posts: 115
Hi Nav Guys,

Is there any way to write a error log in Event Viewer from Navision??
(using Automation/OCX Control)

Our company customized Job Scheduling functionality in which i do generate error log in one table but Client wants same kind of log in Event Viewer also.
Best Regards,
Mahesh Jain
mahesh@reliconservices.com

Comments

  • EddieEddie Member Posts: 26
    If job scheduling is handled by NAS (navision application server) then error messages will occur in event viewer automatically.
  • garakgarak Member Posts: 3,263
    if you use NAS for sheduling, he writes autom. all errors in Event log.
    If you use a client and you will write data in Event Log u can do this with WSH-Shell. Search the Forum for WSH Shell

    Regards
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    garak wrote:
    if you use NAS for sheduling, he writes autom. all errors in Event log.
    If you use a client and you will write data in Event Log u can do this with WSH-Shell. Search the Forum for WSH Shell

    Regards
    I just want to add that part of the WSH-shell is function "LogEvent"... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    right ;-)
    I#ve not say this, because i would, that the user use her brain ;-)
    Do you make it right, it works too!
  • rajpatelbcarajpatelbca Member Posts: 178
    hi kine,

    i want to know the parameter to logevent method. give me some example of this.

    [BOOL LogEvent :=] WindowShell.LogEvent(VAR VARIANT Type, BSTR Message[, BSTR Target])

    eg.
    WindowShell.LogEvent('Error','this is an error message');

    i have written this code. but it is showing me an error [-o<
    Experience Makes Man Perfect....
    Rajesh Patel
  • kinekine Member Posts: 12,562
    Because the first parameter is variant, you need to define Variant variable and use it as the first parameter. For details there is the original help for this function:

    http://msdn.microsoft.com/en-us/library/b4ce6by3(VS.85).aspx
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rajpatelbcarajpatelbca Member Posts: 178
    i have solved this problem. :D


    CREATE(WindowShell);
    WindowShell.CurrentDirectory(ENVIRON('windir') + '\system32\');
    txtCommand := '1';
    IF WindowShell.LogEvent(txtCommand,'hi') THEN
    MESSAGE('sucessful')
    ELSE
    MESSAGE('false');


    in above code i was using txtCommand := 'Error' instead of txtCommand := '1' .

    thank you everybody for your kind support.
    =D> =D> =D>

    Regards,
    Experience Makes Man Perfect....
    Rajesh Patel
  • maheshmahesh Member Posts: 115
    thanx to all.
    problem is solved.

    Control Panel->Administrative Tools->Event Viewer.
    Event Viewer Window contains fields Type,Date,Time, Source, Category, Event ID, User, Computer.

    But im still seeking to fill fields like Category & Source from Navision.
    currently by default
    Type:Error
    Source: WSH (Windows Shell)
    Category : None
    Event ID: 1

    Can i have Source:"MS Navision" & Category:"PDF Print"???
    Best Regards,
    Mahesh Jain
    mahesh@reliconservices.com
  • gycsiakgycsiak Member Posts: 19
    edited 2019-11-25
    I am using this in a codeunit's TryFunction in Dynamics NAV 2017 to collect some client-side information into a remote server's Event Log and it works:
    Name	DataType	Subtype	Length
    lEventLogObject	DotNet	System.Diagnostics.EventLog.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    pDebugMessage: Text
    
    CLEAR(lEventLogObject);
    lEventLogObject := lEventLogObject.EventLog('Application','remoteserver.companydomain.local','NAVDebugLog');
    lEventLogObject.WriteEntry(pDebugMessage);
    
Sign In or Register to comment.