for roughly 20 seconds wait:
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Using an XML configuration file for Log::Log4perl
XML configuration file:
<!--
* General configuration for log4perl
* LOGFILE.filename may be set by the application
* All logging goes to STDOUT (CONSOLE)
-->
<log4perl>
<log4perl.rootlogger>WARN, CONSOLE, LOGFILE</log4perl.rootLogger>
<log4perl.appender.console>Log::Log4perl::Appender::Screen</log4perl.appender.CONSOLE>
<log4perl.appender.console.layout>PatternLayout</log4perl.appender.CONSOLE.layout>
<log4perl.appender.console.layout.conversionpattern>[%d] [%p %c] - %m%n</log4perl.appender.CONSOLE.layout.ConversionPattern>
<log4perl.appender.logfile>Log::Log4perl::Appender::File</log4perl.appender.LOGFILE>
<!-- Let logging come to STDERR on the console, and *pipe* into a log so that unexpected errors are caught
<log4perl.appender.logfile.filename>/optional/absolute/path/to/logfile.log</log4perl.appender.LOGFILE.filename>
-->
<log4perl.appender.logfile.mode>append</log4perl.appender.LOGFILE.mode>
<log4perl.appender.logfile.layout>PatternLayout</log4perl.appender.LOGFILE.layout>
<log4perl.appender.logfile.layout.conversionpattern>[%d] [%p %c] - %m%n</log4perl.appender.LOGFILE.layout.ConversionPattern>
<!-- Add different log levels for specified modules
<log4perl.logger.clickthrough.transform>INFO</log4perl.logger.ClickThrough.Transform>
-->
</log4perl>
How to read the configuration:
my $log4perl = XML::Simple->new(ForceArray=>0, KeyAttr=>[])->XMLin( $log4perl_config_filename );
my $logname = $0;
$logname =~ s/\.pl$/.log/;
$log4perl->{'log4perl.appender.LOGFILE.filename'} = $logname;
Log::Log4perl::init($log4perl);
my $logger = Log::Log4perl->get_logger(__PACKAGE__);
<!--
* General configuration for log4perl
* LOGFILE.filename may be set by the application
* All logging goes to STDOUT (CONSOLE)
-->
<log4perl>
<log4perl.rootlogger>WARN, CONSOLE, LOGFILE</log4perl.rootLogger>
<log4perl.appender.console>Log::Log4perl::Appender::Screen</log4perl.appender.CONSOLE>
<log4perl.appender.console.layout>PatternLayout</log4perl.appender.CONSOLE.layout>
<log4perl.appender.console.layout.conversionpattern>[%d] [%p %c] - %m%n</log4perl.appender.CONSOLE.layout.ConversionPattern>
<log4perl.appender.logfile>Log::Log4perl::Appender::File</log4perl.appender.LOGFILE>
<!-- Let logging come to STDERR on the console, and *pipe* into a log so that unexpected errors are caught
<log4perl.appender.logfile.filename>/optional/absolute/path/to/logfile.log</log4perl.appender.LOGFILE.filename>
-->
<log4perl.appender.logfile.mode>append</log4perl.appender.LOGFILE.mode>
<log4perl.appender.logfile.layout>PatternLayout</log4perl.appender.LOGFILE.layout>
<log4perl.appender.logfile.layout.conversionpattern>[%d] [%p %c] - %m%n</log4perl.appender.LOGFILE.layout.ConversionPattern>
<!-- Add different log levels for specified modules
<log4perl.logger.clickthrough.transform>INFO</log4perl.logger.ClickThrough.Transform>
-->
</log4perl>
How to read the configuration:
my $log4perl = XML::Simple->new(ForceArray=>0, KeyAttr=>[])->XMLin( $log4perl_config_filename );
my $logname = $0;
$logname =~ s/\.pl$/.log/;
$log4perl->{'log4perl.appender.LOGFILE.filename'} = $logname;
Log::Log4perl::init($log4perl);
my $logger = Log::Log4perl->get_logger(__PACKAGE__);
Confluence calendar
{calendar:id=nameOfCalendar|title=Title of Calendar|defaultView=month}
It publishes in iCal.
Labels:
calendar,
confluence,
wiki
Simple Perl CGI and LWP
#!/usr/bin/perl
use CGI;
my $q = CGI->new;
print $q->header();
my $url = $q->param('url');
###
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->proxy('http', 'http://your_proxy_here:80');
my $response = $ua->get($url);
if ($response->is_success) {
print $response->content; # or do fancy stuff here
}
else {
die $response->status_line;
}
use CGI;
my $q = CGI->new;
print $q->header();
my $url = $q->param('url');
###
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->proxy('http', 'http://your_proxy_here:80');
my $response = $ua->get($url);
if ($response->is_success) {
print $response->content; # or do fancy stuff here
}
else {
die $response->status_line;
}
Subscribe to:
Posts (Atom)