I am trying to use Log4Perl in an application using CGI::Application and running under #!/usr/bin/speedy. I always get this error Internal Error: Root Logger not initialized. Here is my code snippet.
I have a Wrapper Module for Logger Logger.pm
use Log::Log4perl;
sub set_session_id {
my ($class) = shift;
my ($session_id) = shift;
unless(Log::Log4perl->initialized()) {
Log::Log4perl->init_once('/opt/httpd/logger.conf');
$Log::Log4perl::caller_depth = 1;
my $user_id = $ENV{USER} || $ENV{LOGNAME} || $ENV{USERNAME} || $EN
+V{REMOTE_
USER} || $<;
Log::Log4perl->get_logger("esc");
Log::Log4perl::MDC->put("user_id", $user_id);
Log::Log4perl::MDC->put("session_id", $session_id);
}
return Log::Log4perl->get_logger("esc");
}
and my logger.conf is
log4perl.logger.esc=DEBUG, DBAppndr
#log4perl.rootLogger=DEBUG, DBAppndr
log4perl.appender.DBAppndr=Log::Log4perl::Appender::DBI
log4perl.appender.DBAppndr.datasource=dbi:Oracle:data
log4perl.appender.DBAppndr.username=user
log4perl.appender.DBAppndr.password=passwd
log4perl.appender.DBAppndr.sql=insert into ESC_APP_LOG (LOG_LEVEL, LOG
+GER_NAME, MODULE, APP_ID, CLASS, METHOD, LINE_NO, HEADING, USER_ID, M
+SG, LOGGER_ID) values (?,?,?,?,?,?,?,?,?,?,?)
etc
and in my cgiapp_init sub routine I call logger as below
my $logger = Logger->set_session_id($self->param('session'));
$self->param('logger'=> $logger);
when I start my application, I get this error
"Error executing class callback in init stage: Internal error: Root Logger not initialized."
I am not sure what I am doing wrong. any help solve my problem is appreciated. Thanks in advance for your help.
Thanks
Prakash
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.