Log4perl with and without mod_perl

Log4perl with and without mod_perl

am 22.11.2010 16:34:46 von E R

I was wondering if anyone has come up with a solution to this problem:

1. You have a mod_perl application and use Log4perl for logging.
2. There is a module in your mod_perl app that you want to use outside
of the mod_perl environment (e.g. in a script run from the command
line)
3. That module uses Log4perl for logging, so you need to initialize
the logging environment.
4. However, there are some aspects of the Log4perl configuration that
are not relevant or you don't want to use when using the module
outside of the mod_perl environment.

One example for #4 would be the filename property for the appender
Log::Log4perl::Appender::File. In your mod_perl app you make want a
particular path configured, but when running a script from the command
line you may want all logging output to go to stdout/stderr. On the
other hand, there are some aspects of the Log4perl configuration which
would be common to both scenarios - like the layout.

This is really more of a Log4perl question than a mod_perl one, but I
figure mod_perl users might have a better chance of running into this
problem.

Any good solutions out there?

Thanks,
ER