I use a log4perl config file, and I have two appenders -- one is for INFO and above and is a screen appender (web server logs), and the other is for ERROR and is directed to a separate file.
For *only *WARN and above messages I want to include a dump of request parameters in the log message. That is, for INFO messages I don't want to include the parameters. That's pretty easy for normal exceptions. At the end of a request I look for $c->error and when found I use Log::Log4perl::MDC->put( params => Dumper $c->req->parameters ) to include the params in the log using %X{params}. (Except, I sanitize the params first -- e.g. replace values that match /password/). I'd like to find a more generic way, and something that will work for calling $c->log->warn and $c->log->error directly, too. (I also trap __WARN__ and __DIE__ to use log4perl and dump a stack trace). Again, I don't want the params in all messages, so I don't want to set Log4perl::MDC->put( params => $dump ) at the start of each request. I only want to do that for WARN and ERROR messages. Should I put $c->req->parameters in a global at the start of each request and then wrap the warn() and error() methods and set the MDC params in those methods? Monkey-patch (redefined) the warn() and error() log methods each request with the current params? Neither of those sound that great. Is there an approach I'm missing? Thanks, -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/