Hi,

I am a relative newbie and I hope I ask in the right place.

The problem is that Log4perl doesn't find the .conf file when the current
directory is not where the .conf file is.

My Perl package is delivered as a directory with the main file DXMain.pl and
all its private modules, including my KConfig.conf Log4Perl configuration
file. I have no way to know in advance where the end-user is going to put
this directory in the file system (nor is it appropriate to impose it).

Log4Perl is initialized with:

    Log::Log4perl::init('KConfig.conf');

If the user 'chdir' into this directory before running the main file, all is
well: KConfig.conf is found just fine.

However, the user can also call me from another directory using a qualified
path, eg 'perl /path/to/DXMain.pl parameters'. Then the initialization line
above breaks, as the config file cannot be found.

I have a similar issue with my "use" statements for my private modules,
which I was able to solve using an idiom like:

    use FindBin;
    use lib "$FindBin::Bin";

A similar idiom seems to work also for Log4Perl config file:

    use FindBin;
    Log::Log4perl::init("$FindBin::Bin/KConfig.conf");

Is this the correct and idiomatic way to solve my issue?

The only other way I can see is to change at start time the Cwd to be
$FindBin::Bin (or some equivalent parsed from $0).

As an unrelated issue, I had a hard time using the appender threshold
feature to implement the FAQ " How can I collect all FATAL messages in an
extra log file?".

The FAQ solution did not work, because I had an additional line at the top
of my .conf file reading:

    log4perl.threshold = INFO

And then my FATAL log file was also clobbered by all messages of level INFO
or higher.

Contrary to [my understanding of] what the doc says, setting the system wide
log4perl.threshold doesn't only remove all messages of lower priority, it
also in effect disables all appender thresholds, even if they are more
selective.

Is this the intent? This tends to defeat the purpose of log4perl.threshold
IMHO.

Best regards and thanks,

Jean-Denis





------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to