Different threads will have separate private copies of the Log::Log4perldata structures, so any changes you make in one thread will not affect another.
I can think of three solutions to your problem.
- Make the Log4perl data structure shared between threads. This might not work if Log4perl is not thread safe.
- Find a way of signalling between threads via another shared variable, sockets, signals etc, so they all change their log level at once.
- Make changes to the log4perl config file, and take advantage of the fact that log4perl can watch for changes and automatically reload the file,
Of the three options, I think the third is probably the most reliable and safest in the long term.
I would also ask why you are changing the log level at runtime?
If it is as a response to an exceptional situation, then it would probably be better to log at a higher level to begin with, and adjust the retention of those detailed log files in response to a problem.
Also it is worth noting that you can have different log4perl configurations for different classes within you perl program, so that would be another way of having more detailed logging for an area that deserves more logging.
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.