added Chris Donnelly's changes, plus a test case plus documentation
mschilli
21 years ago
5 | 5 |
* Threshold settings of appenders:
|
6 | 6 |
$appender->threshold($ERROR);
|
7 | 7 |
log4j.appender.A.Threshold = ERROR
|
|
8 |
* Chris R. Donnelly <cdonnelly@digitalmotorworks.com>
|
|
9 |
submitted two patches:
|
|
10 |
- extended init() to take obj references
|
|
11 |
- fixed %F and %L if Log4perl is used by a wrapper class (accepted,
|
|
12 |
but changed variable name to Log::Log4perl::caller_depth as
|
|
13 |
a tribute to Log::Dispatch::Config, added test case 022Wrap
|
|
14 |
and documentation
|
8 | 15 |
|
9 | 16 |
0.21 8/08/2002
|
10 | 17 |
* Synopsis shows code samples in Log4perl.pm/README
|
700 | 700 |
them to tune the logging to their needs.
|
701 | 701 |
|
702 | 702 |
Cool Tricks
|
|
703 |
Shortcuts
|
703 | 704 |
When getting an instance of a logger, instead of saying
|
704 | 705 |
|
705 | 706 |
use Log::Log4perl;
|
|
710 | 711 |
|
711 | 712 |
use Log::Log4perl qw(get_logger);
|
712 | 713 |
my $logger = get_logger();
|
|
714 |
|
|
715 |
Alternative initialization
|
|
716 |
Instead of having "init()" read in a configuration file, you can also
|
|
717 |
pass in a reference to a string, containing the content of the file:
|
|
718 |
|
|
719 |
Log::Log4perl->init( \$config_text );
|
|
720 |
|
|
721 |
Also, if you've got the "name=value" pairs of the configuration in a
|
|
722 |
hash, you can just as well initialized "Log::Log4perl" with a reference
|
|
723 |
to it:
|
|
724 |
|
|
725 |
my %key_value_pairs = (
|
|
726 |
"log4j.rootLogger" => "error, LOGFILE",
|
|
727 |
"log4j.appender.LOGFILE" => "Log::Dispatch::File",
|
|
728 |
...
|
|
729 |
);
|
|
730 |
|
|
731 |
Log::Log4perl->init( \%key_value_pairs );
|
713 | 732 |
|
714 | 733 |
How about Log::Dispatch::Config?
|
715 | 734 |
Yeah, I've seen it. I like it, but I think it is too dependent on
|
225 | 225 |
|
226 | 226 |
my @text;
|
227 | 227 |
|
228 | |
if (ref $config) {
|
|
228 |
if (ref($config) eq 'HASH') { # convert the hashref into a list
|
|
229 |
# of name/value pairs
|
|
230 |
@text = map { $_ . '=' . $config->{$_} } keys %{$config};
|
|
231 |
} elsif (ref $config) {
|
229 | 232 |
@text = split(/\n/,$$config);
|
230 | 233 |
}else{
|
231 | 234 |
Log::Log4perl::Logger::set_file_to_watch($config);
|
908 | 908 |
|
909 | 909 |
=head1 Cool Tricks
|
910 | 910 |
|
|
911 |
=head2 Shortcuts
|
|
912 |
|
911 | 913 |
When getting an instance of a logger, instead of saying
|
912 | 914 |
|
913 | 915 |
use Log::Log4perl;
|
|
918 | 920 |
|
919 | 921 |
use Log::Log4perl qw(get_logger);
|
920 | 922 |
my $logger = get_logger();
|
|
923 |
|
|
924 |
=head2 Alternative initialization
|
|
925 |
|
|
926 |
Instead of having C<init()> read in a configuration file, you can
|
|
927 |
also pass in a reference to a string, containing the content of
|
|
928 |
the file:
|
|
929 |
|
|
930 |
Log::Log4perl->init( \$config_text );
|
|
931 |
|
|
932 |
Also, if you've got the C<name=value> pairs of the configuration in
|
|
933 |
a hash, you can just as well initialized C<Log::Log4perl> with
|
|
934 |
a reference to it:
|
|
935 |
|
|
936 |
my %key_value_pairs = (
|
|
937 |
"log4j.rootLogger" => "error, LOGFILE",
|
|
938 |
"log4j.appender.LOGFILE" => "Log::Dispatch::File",
|
|
939 |
...
|
|
940 |
);
|
|
941 |
|
|
942 |
Log::Log4perl->init( \%key_value_pairs );
|
921 | 943 |
|
922 | 944 |
=head1 How about Log::Dispatch::Config?
|
923 | 945 |
|