Thursday, January 27, 2011

Logging to Windows Event Log using JScript

This handy function allows you to log to the Windows Event Log using JScript, for example from a classic ASP web page:

function Log(message) {
    var shell = new ActiveXObject("WScript.Shell")
    shell.Exec('eventcreate /id 1 /l [LOG] /SO [SOURCE] /T ERROR /D "' + String(message).replace('"', '""') + '"')
}

0 comments:

Post a Comment