Codebase list liblog-log4perl-perl / 547340b
added Chris Donnelly's changes, plus a test case plus documentation mschilli 21 years ago
4 changed file(s) with 52 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
55 * Threshold settings of appenders:
66 $appender->threshold($ERROR);
77 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
815
916 0.21 8/08/2002
1017 * Synopsis shows code samples in Log4perl.pm/README
700700 them to tune the logging to their needs.
701701
702702 Cool Tricks
703 Shortcuts
703704 When getting an instance of a logger, instead of saying
704705
705706 use Log::Log4perl;
710711
711712 use Log::Log4perl qw(get_logger);
712713 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 );
713732
714733 How about Log::Dispatch::Config?
715734 Yeah, I've seen it. I like it, but I think it is too dependent on
225225
226226 my @text;
227227
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) {
229232 @text = split(/\n/,$$config);
230233 }else{
231234 Log::Log4perl::Logger::set_file_to_watch($config);
908908
909909 =head1 Cool Tricks
910910
911 =head2 Shortcuts
912
911913 When getting an instance of a logger, instead of saying
912914
913915 use Log::Log4perl;
918920
919921 use Log::Log4perl qw(get_logger);
920922 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 );
921943
922944 =head1 How about Log::Dispatch::Config?
923945