Hi,

First of all, thanks a lot for this great module!

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

and then I add appenders as needed, via the API:

In a Mason component:

    $logger = Log::Log4perl->get_logger('Netdot::Model::Device');

    # 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);
    }
    $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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to