How to log into Event Viewer

maheshmahesh Posts: 115Member
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
[email protected]

Comments

  • EddieEddie Posts: 26Member
    If job scheduling is handled by NAS (navision application server) then error messages will occur in event viewer automatically.
  • garakgarak Posts: 3,263Member
    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 Posts: 12,562Member
    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 Posts: 3,263Member
    right ;-)
    I#ve not say this, because i would, that the user use her brain ;-)
    Do you make it right, it works too!
  • rajpatelbcarajpatelbca Posts: 178Member
    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 Posts: 12,562Member
    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 Posts: 178Member
    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 Posts: 115Member
    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
    [email protected]
  • gycsiakgycsiak Posts: 13Member
    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.