Hi, I have an interesting problem: I have derived a customised logger, say, DBLogger from the log4cxx::Logger class, which is using a customised factory, say, DBFactory. We have a thin layer on top of log4cxx with our own Logger class encapsulating the underlying log4cxx logger class, or in that case, encapsulating the DBLogger extension class. We also have a LogManager of our own which handles our map of wrapper loggers by their names.
The Problem: It seems that whenever a logger name is defined in a log4cxx configuration file, is actually being created dynamically by log4cxx using of course the default factory rather than our own DBFactory class. When we come to create this logger (i.e. when the user actually wants to log with the logger), though this logger is not in our own logmanager map at that stage it is already in log4cxx::LogManager map, so we get back an already existing log4cxx::Logger, and effectively try to cast it into a customised DBLogger (since we have a member of DBLogger inside each wrapper logger), which of course results with a zeroed pointer and a segmentation fault. Now, I know that one can write <categoryFactory class="DBFactory"/> in the configuration file to tell log4cxx to use DBFactory for the loggers it needs to create dynamically, but that puts too much responsibility on our users, which may get to a lot of trouble if they forgot to set it. (even if we can robustly prevent the segmentation fault, we are enforced to use Logger instead of DBLogger in this case). A good solution would be to be able to programmatically set the "default" factory globally on log4cxx framework level even before configuration starts, rather than just for the context of the dynamic loggers created during the configuration stage. Lastly, I have a possible solution which I need to sanity check: Let's say in my own logging wrapper I decide to add a "." postfix to each logger-name I create. That means that if the user has actual loggers "A" and "A.B", I create instead loggers "A." and "A.B." If the user set these loggers in her configuration file, then log4cxx will create loggers "A" and "A.B" (without the ".") when actual logging occurs, my framework will use "A." and "A.B." which will be customised loggers created via DBFactory and, AND HERE COMES THE QUESTION, possibly with correct hierarchy, that is, "A."-->"A" and "A.B."-->"A.B" Will that work? Will these loggers get *always* the correct attributes from the hierarchy, or maybe because "." has some special meaning this may fail? Sorry for the verbosity, but it's a tough one, Thanks, Barak ________________________ Barak Simon GED IT Core Platform Deutsche Bank 190 George St. Sydney, 2000 Phone +61 2 925 85070 Fax +61 2 925 95050 -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
