Slide 23
Slide 23 text
ログを出力する(Plack)
23
use File::Spec::Functions qw(catfile);
use File::RotateLogs;
$logger = File::RotateLogs->new(
logfile => catfile('/var/log/plack', "$project_name.access.%Y_%m%d.log"),
linkname => catfile('/var/log/plack', "$project_name.access.log"),
);
enable 'AxsLog',
logger => sub { $logger->print(shift); },
error_only => ($ENV{PLACK_ENV} || '') eq 'production' ? 1 : 0,
long_response_time => ($ENV{PLACK_ENV} || '') eq 'production' ? 0.3 : 0,
format => join(
"\t",
'time:%{%Y-%m-%dT%H:%M:%S%z}t',
'host:%h',
'vhost:%{Host}i',
'user:%u',
'method:%m',
'protocol:%H',
'uri:%U%q',
'status:%>s',
'ua:%{User-agent}i',
'referer:%{Referer}i',
'size:%b',
'retime:%T',
'runtime:%{X-Runtime}o',
'pid:%P',
);