I would like to have modules that control their logging at runtime, but without using just one monolithic configuration file. When you work with processes running under different permissions, I really do not want to deal with every process that should have access to every log in the system when they write only a subset of them.
However, I did not find much documentation in the Log4perl manual on how to initialize additional applications from the configuration file at run time. http://metacpan.org/pod/Log::Log4perl::Appender refers to the add_appender method, but works with instances of appender objects instead of conf files. It also does not define journal objects and registrar-> attachment relationships.
I tried using every init package from my own conf, but it just grabs the existing configuration every time it gets initialized. What I would like to do is something like:
my $foo = Foo->new() ## Checks Log::Log4perl::initialized(), sees that it ## hasn't been initalized yet, inits Log4perl from foo.conf my $bar = Bar->new() ## Checks Log::Log4perl::initialized(), sees that it ## has been initalized. Adds appenders and loggers defined ## in bar.conf into the initialized configuration
How can I parse and add a configuration to the current configuration?
Edit: Probalem using a package variable is that it is simply the Moose role consumed by the various classes, pretty much just the MooseX :: Role :: Parameterized version of the Ether response in Creating Self-Service Modules with Log :: Log4perl . Thus, my registrar is populated into the library that consumes it, and I do not have a global variable that I can work with every time I use it.
Although..
If I declare a global variable outside the MooseX :: Role :: Parameterized role block, will each class that uses this role use the same conf variable?
logging perl log4perl
Oesor
source share