|
From: Mike S. <m...@pe...> - 2007-06-08 02:37:14
|
On Thu, 7 Jun 2007, Carlos Vicente wrote:
> First of all, thanks a lot for this great module!
You're welcome :).
> ... and then I add appenders as needed, via the API: In a Mason
> ...
> # Notice that I intentionally undef the object in order to call
> DESTROY and make sure the string
> # is not being used (wasting memory) except when this component is
> called
> if ( $logstr = Log::Log4perl::appender_by_name('updatedevice.html') ){
> undef($logstr);
> }
Hmm. First off, in your configuration is no appender named
'updatedevice.html', so appender_by_name will return undef. Even if
'updatedevice.html' existed and appender_by_name returned an
object, calling undef() on it isn't the right way to get rid of it.
There's a method called eradicate_appender() for that:
"To eradicate an appender from the system,
you need to call
Log::Log4perl->eradicate_appender($appender_name)
which will first remove the appender from every logger in the system
and then will delete all references Log4perl holds to it."
Give it a whirl and let me know how it works out!
-- Mike
Mike Schilli
m...@pe...
> I'm working on a project with libraries accessible via both a web
> front-end (HTML::Mason, mod_perl) and command line scripts. Most of
> the logging is intended for Syslog, but in some cases I temporarily
> use the Screen appender (command-line) and the String appender for
> output to the web.
>
> My initial config looks like:
>
> log4perl.oneMessagePerAppender = 1
> log4perl.category.Netdot = ERROR, Syslog
> log4perl.category.Netdot::Model = INFO, Syslog
> log4perl.category.Netdot::Model::Device = INFO, Syslog
> log4perl.category.Netdot::UI = INFO, Syslog
> log4perl.appender.Syslog = Log::Dispatch::Syslog
> log4perl.appender.Syslog.ident = netdot
> log4perl.appender.Syslog.facility = local0
> log4perl.appender.Syslog.min_level = debug
> log4perl.appender.Syslog.layout =
> Log::Log4perl::Layout::SimpleLayout
>
> $logstr =
> Log::Log4perl::Appender->new(Log::Log4perl::Appender::String,
> name=>'updatedevice.html')
> $logger->add_appender($logstr);
>
> ... (stuff that produces log output)
>
> # somewhere in the presentation code:
> print $logstr->string();
>
> # at the end:
> undef($logstr) if defined $logstr;
>
>
> The problem is my results are intermittent. Sometimes I see the output
> in the web page, sometimes I don't. I'm not sure what I'm doing wrong
> here. Any ideas? Suggestions on how to do this some other way?
>
> Thanks in advance.
>
> cv
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|