package Log::Log4perl::Config::Standalone; use Log::Log4perl::Config; use Log::Log4perl::Config::PropertyConfigurator; use Carp; sub new { my ($class, $filename) = @_; confess "configuration '$filename' not found\n" unless -f $filename; my $cp = Log::Log4perl::Config::PropertyConfigurator->new; $cp->file( $filename ); my $self = { data => $cp->parse() }; return bless $self, $class; } sub value { my ($self, $path, $default) = @_; my @p = split /\./, $path; shift @p if $p[0] eq 'log4perl'; my $found = 1; my $r = $self->{data}; while (my $n = shift @p) { if (exists $r->{$n}) { $r = $r->{$n}; } else { $found = 0; } } return $found ? $r->{value} : $default; } 1; __END__