in reply to [log4perl] log level vs. threads
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: [log4perl] log level vs. threads
by menth0l (Monk) on Aug 31, 2011 at 11:11 UTC | |
by Old_Gray_Bear (Bishop) on Aug 31, 2011 at 11:51 UTC | |
by Anonymous Monk on Mar 11, 2012 at 23:42 UTC |