MojoX::Log::Dispatch is a Perl wrapper around Log::Dispatch module. Log::Dispatch manages a set of Log::Dispatch::* objects, allowing you to add and remove output objects as desired.
Include log statements at various levels throughout your code. Then when you create the new logging object, set the minimum log level you want to keep track off. Set it low, to 'debug' for development, then higher in production.
# Create a Log::Dispatch whith logging object that will log to STDERR by default
# or to file if exists attribute path
my $log = MojoX::Log::Dispatch->new();
$log->add(Log::Dispatch::File->new(name => 'file1',
min_level => $self->level,
filename => 'logfile'
#Add some exotic loggers
$log->add(Log::Dispatch::Twitter->new( username => "foo",
password => "bar",
min_level => "critical",
name => "twitter",
#and now as in Mojo::Log
$log->debug("Why isn't this working?");
$log->info("FYI: it happened again");
$log->warn("This might be a problem");
$log->error("Garden variety error");
$log->critical("This might be a BIG problem");
$log->warning("This might be a problem");#=warn
$log->notice("it happened again");
$log->log('debug' => 'This should work');
#In your Mojo App
# create a custom logger object for Mojo/Mojolicious to use
# (this is usually done inside the "startup" sub on Mojolicious).
my $dispatch = MojoX::Log::Dispatch->new('path' => '/home/green/tmp/mySupEr.log',
'remove_default_log_obj' => 0);
$dispatch->add(Log::Dispatch::Syslog->new( name => 'logsys',
min_level => 'debug',
ident => 'MyMojo::App',
facility => 'local0' )
$self->log->debug("Why isn't this working?");