From: Kevin G. <ke...@go...> - 2002-09-18 21:53:37
|
Jose, this works for me, I get an email just fine, note that mail.server should be your outgoing smtp server, right? --------------------------------------------- use Log::Log4perl; Log::Log4perl->init(\' log4perl.logger.Veronicad=DEBUG, screen, mail log4perl.appender.screen=Log::Dispatch::Screen log4perl.appender.screen.stderr=0 log4perl.appender.screen.layout=Log::Log4perl::Layout::PatternLayout log4perl.appender.screen.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n log4perl.appender.mail=Log::Dispatch::Email::MailSend log4perl.appender.mail.name=Veronicad log4perl.appender.mail.subject=Veronicad event log4perl.appender.mail.to=yo...@yo... *** log4perl.appender.mail.from=yo...@yo... *** log4perl.appender.mail.buffered=0 log4perl.appender.mail.server=mail.yourdomain.com *** log4perl.appender.mail.layout=Log::Log4perl::Layout::PatternLayout log4perl.appender.mail.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n '); my $logger = Log::Log4perl::get_logger("Veronicad"); $logger->error("Testing errors"); --------------------------------------------------------------- Jose Vicente Nunez Zuleta wrote: > First of all thanks for this cool port of the Log4j API; This tool is going to make our lives easier :) > > So far i managed to add the logging functionality to my application (part of my perl code): > > use constant OK_CODE => 0; > use constant ERROR_CODE => 1; > use constant LOG_CONFIG => "/usr/local/sysadmin/VeronicadLog4perl.properties"; > use constant REFRESH_LOG_CONFIG => 300; > > # ----- END User configurable parameters -------- > > # Start the logger > Log::Log4perl->init_and_watch(LOG_CONFIG, REFRESH_LOG_CONFIG); > my $logger = get_logger("Veronicad"); > > $logger->error("Testing errors"); > > And here is my configuration file info with three appenders: > > log4perl.logger.Veronicad=DEBUG, syslog, screen, mail > log4perl.appender.screen=Log::Dispatch::Screen > log4perl.appender.screen.stderr=0 > log4perl.appender.screen.layout=Log::Log4perl::Layout::PatternLayout > log4perl.appender.screen.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n > log4perl.appender.syslog=Log::Dispatch::Syslog > log4perl.appender.syslog.name=Veronicad > log4perl.appender.syslog.facility=daemon > log4perl.appender.syslog.socket=inet > log4perl.appender.syslog.layout=Log::Log4perl::Layout::PatternLayout > log4perl.appender.syslog.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n > log4perl.appender.mail=Log::Dispatch::Email::MailSend > log4perl.appender.mail.name=Veronicad > log4perl.appender.mail.subject=Veronicad event > log4perl.appender.mail.to=my...@em...dress > log4perl.appender.mail.from=sm...@em...dress > log4perl.appender.mail.buffered=0 > log4perl.appender.mail.server=my.mail.server <--- NOT SURE ABOUT THIS!!!!!! > log4perl.appender.mail.layout=Log::Log4perl::Layout::PatternLayout > log4perl.appender.mail.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n > > But the application doesn't sends an email when i got an error (just runs without sending the email): > > bash-2.04# ./Veronicad.pl > 2002/09/18 14:36:16 ERROR> Veronicad.pl:34 main:: - Testing errors > 2002/09/18 14:36:16 INFO> Veronicad.pl:45 main:: - [Server ./Veronicad.pl accepting clients] > > > So far reading the man page i found that "Log::Dispatch::Email::MailSend" is a subclass of 'Mail::Send' wich also inherits > from 'Mail::Mailer'. 'Mail::Mailer' can specify to use an external SMTP server like this: > > ""smtp"" > Use the "smtp" protocol via Net::SMTP to deliver the > mail. The server to use can be specified in "@args" > with > > $mailer = new Mail::Mailer 'smtp', Server => $server; > > The smtp mailer does not handle "Cc" and "Bcc" lines, > neither their "Resent-*" fellows. The "Debug" options > enables debugging output from "Net::SMTP". > > > How i can achieve the same using 'Log::Dispatch::Email::MailSend' class? > > There is a environment variable i can set so i can force the ussage of this SMTP server? > > There is a way to debug if this is working? > > I can send email using the external mail server using Net::SMTP and that class is already installed on my system. > > Thanks in advance, > > Jose Vicente. > > > -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |