|
Log Object |
|
See Also: |
The Log.Flags property sets/returns flags that control what information is logged.
VBScript:
JScript:
| Log | The Log object. |
| flags | An ORed combination of ApgLogFlags values. |
See ApgLogFlags Enum for a list of the flags values.
Five flags act as a filter for Log.Write(): If the apgLogFatalErrors flag is on, then calling Log.Write() with apgSeverityFatal will write an entry to the log file. If the apgLogFatalErrors flag is off, then calling Log.Write() with apgSeverityFatal will not write a log entry. Similarly, the apgLogErrors flag determines whether calling Log.Write() with apgSeverityError writes an entry, and so on. If no flags are on (apgLogNothing), calls to Log.Write() will do nothing. The first 5 flags do not affect Log.LogEvent().
Log.Write() is called from the default error handler when an error occurs. Clearing any of the first 5 flags affects whether these errors are written to the log, as well as whether Log.Write() calls from script are written to the log.
The flags apgEventLogFatalErrors and apgEventLogErrors determine whether errors are reported to the NT Event log. The NT Event Log provides a standard, centralized way for applications to record important software and hardware events. Windows NT supplies the Event Viewer for viewing and filtering the Event Log, and a programming interface for examining the Log. In addition, administrators can view Event Logs on remote computers, and many system management tools provide access to Event Logs.
If the apgEventLogFatalErrors flag is on, then fatal errors are reported to the NT Event Log, unless the script is debugged when the fatal error occurs. If the apgEventLogErrors flag is on, then all errors (fatal and non-fatal) are reported to the NT Event Log, unless the script is debugged when the error occurs. There are no flags for reporting warnings and information to the event log, but custom error handlers can be used that call Log.LogEvent().
If a script is debugged when a fatal error occurs, that error will not be reported to the NT Event Log, regardless of the Log.Flags setting. This is so the Event Log does not get filled up when a developer is debugging scripts.
The default value for Log.Flags is obtained from the registry:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\WebGecko\APGen\Defaults
DWORD Value: "Log.Flags"
When APGen is installed, this value is set to 0x0f, which is apgLogDefault. If you would like to change the default Log.Flags value on a system-wide basis, you can, by changing this registry setting.
This VBScript code snippet causes all information to be logged to the log file, and fatal errors to be logged to the NT Event Log:
Log.Flags = apgLogDefault Or apgEventLogFatalErrors
A JScript code snippet that accomplishes the same thing:
Log.Flags = apgLogDefault | apgEventLogFatalErrors;