NAME

Log::Log4perl::Appender::Chunk::Store - Store adapter baseclass

DESCRIPTION

This is the baseclass for all Store adapters used by the Log::Log4perl::Appender::Chunk appender.

IMPLEMENTING YOUR OWN

Write your subclass

Make a Moose subclass of this and implement the 'store' method.

Have a look at the minimalistic code in Log::Log4perl::Appender::Chunk::Store::Memory.

Settings:

Settings should be plain Scalar Moose attributes. They will be injected from the configuration file key 'store_args'.

Use your Store from the config file.

Set the store_class property of your Chunk appender to something like:

log4perl.appender.Chunk.store_class=+My::L4p::Appender::Chunk::Store::MyStorage

Remember you can set some your storage class parameters like:

log4perl.appender.Chunk.store_args.my_setting1=Setting1Value
log4perl.appender.Chunk.store_args.my_setting2=Setting2Value

Use your Store from your application code.

If your Storage is too complex to build itself only from the configuration file properties, you can perfectly build an instance of it and inject it in your Chunk Appender at run time (do that only once right after L4P init):

my $store = .. An instance of your My::L4p::Appender::Chunk::Store::MyStorage
if( my $chunk_appender = Log::Log4perl->appender_by_name('Chunk') ){
  $chunk_appender->store($store);
}

Don't forget to change 'Chunk' by whatever name you gave to your Chunk appender in the config file.

METHODS

store

This method will be called by the Log::Log4perl::Appender::Chunk to store a whole chunk of log lines under the given chunk ID.

Implement it in any subclass like:

sub store{
   my ($self, $chunk_id, $chunk) = @_;
   ...
}