4

If my logging directory (/home/hss/Data/log/DataImport.log) does not exist when log4perl is initializing, then I get this error:

Cannot write to '/home/hss/Data/log/DataImport.log': No such file or directory

Is there a way to make it create the directory by itself without me having to specify the directory anywhere except in my log.conf file?

DVK
  • 126,886
  • 32
  • 213
  • 327
Hari Menon
  • 33,649
  • 14
  • 85
  • 108

2 Answers2

1

From version 1.43 on there is a new parameter called mkpath in Log::Log4perl::Appender::File which creates the directory if it is set to true in the config.

Docu 1.43: http://search.cpan.org/dist/Log-Log4perl-1.43/lib/Log/Log4perl/Appender/File.pm

1

I am quite sure that Log::Log4perl::Appender::File do not create any directories. Probably easiest method would be to subclass it and override file_open method with directory detection/creation code, followed by call original method.

bvr
  • 9,687
  • 22
  • 28