The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Log::Dispatch::Win32EventLog - Class for logging to the Windows NT Event Log

SYNOPSIS

  use Log::Dispatch::Win32EventLog;

  my $log = Log::Dispatch::Win32EventLog->new(
      name       => 'myname'
      min_level  => 'info',
      source     => 'My App'
  );

  $log->log(level => 'emergency', messsage => 'something BAD happened');

DESCRIPTION

Log::Dispatch::Win32EventLog is a subclass of Log::Dispatch::Output, which inserts logging output into the windows event registry.

METHODS

new
  $log = Log::Dispatch::Win32EventLog->new(%params);

This method takes a hash of parameters. The following options are valid:

name
min_level
max_level
callbacks

Same as various Log::Dispatch::* classes.

source

This will be the source that the event is recorded from. Usually this is the name of your application.

The source should not contain any backslash characters.

register

This specifies which event log to register the source with, if you want to register your source, or to post to a log other than the Application log.

When you register a source to particular log, all future events will be posted to that log, even if you unregister the source and attempt to register it to a different log. If you want to change the log, you will have to change the source name.

If you register a source to the Security log, informational events will be tagged as "Audit Success" and higher levels will be tagged as "Audit Failure".

In order to use this feature, you must have Win32::EventLog::Message installed.

log_message

inherited from Log::Dispatch::Output.

OTHER TOPICS

Using with Log4perl

This module can be used as a Log::Log4perl appender. The configuration file should have the following:

  log4perl.appender.EventLog         = Log::Dispatch::Win32EventLog
  log4perl.appender.EventLog.layout  = Log::Log4perl::Layout::SimpleLayout
  log4perl.appender.EventLog.source  = MySourceName
  log4perl.appender.EventLog.Threshold = INFO

Replace MySourceName with the source name of your application.

SEE ALSO

Log::Dispatch, Win32::EventLog, Log::Log4perl

Win32::EventLog::Carp traps warn and die signals and sends them to the NT event log.

AUTHOR

Robert Rothenberg <rrwo at cpan.org>

Arthur Bergman <abergman at cpan.org>

Gunnar Hansson <gunnar at telefonplan.nu>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.