I've been using Log::Log4perl for a few months at work now, and in that time I've noticed that if the configuration file specifies logging to a directory that doesn't exist, Log::Log4perl dies, taking every application using that logging config file with it. The error looks something like:
Can't open logs/BOGUS/foo.log (No such file or directory) at C:/Perl/s
+ite/lib/Log/Log4perl/Appender/File.pm line 102.
Compilation failed in require at...
Since one of my main goals in using Log::Log4perl is to centralize my logging configurations, this means that large subsets of my code base can all go down at once from a typo in that config file. This was an acceptable risk when I was the only developer using the package, and I could trust myself to add the directory to the SVN archive in the same commit as I added the config file change (my logging paths are all under my svn root). Now that most of my team is using Log::Log4perl, there is getting to be too much risk of human failure in that approach.
I already have Log::Log4perl thinly wrapped, so I'm going to add some logic to the wrapper to attempt the initilization in an eval and, if it dies, re-attempt to initilize with a known safe (meaning empty) config file. This way, config file issues will only disable logging, not crash applications. I would like a way to automatically create that directory, however. I've thought about hacking the log4perl code to add this functionality, but I'd like to keep that as a last resort. I'm wondering how other monks have solved this problem before me.
Thanks in advance for your replies.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.