From: <log...@li...> - 2015-02-14 09:23:20
|
On 2015-02-14 09:40, log...@li... wrote: > Hello Sorin, > > When you say log4cplus, I suppose you mean log4cpp actually, don't you? I'm very embarrassed, I actually meant log4cplus and I posted to the wrong mailing list. I apologize for that. But I think the question holds for log4cpp too. > The best thing I may suggest you is that your plugins do not initialize > loggers (or even other resources) themselves, but instead provide API > calls for the user of your plugin library. This way you avoid checks for > sanity and have better control for your resources. Yes, I thought of that too. The problem is that the my "plugins" are apache web server modules and the "user" is the apache web server. So apache will not invoke my API for log4(cpp|cplus) initialization. Moreover, I don't know the set of third party apache modules that co-exist in the web server and how they handle log4cpp properties files. > Several loggers coexist fine as soon as they have different names. If > you ask about ones having same names, you are putting loaded gun into > your pocket. You could do tricks do determine the fact, but it is out of > usage patterns for the library, and I would not advise you to do it. > The common approach for logging is having single log4.properties file > per process no matter how many libraries does it involve. No, I don't have the requirement that the loggers have the same name. The logger name is configurable in my application. However I am concerned about initializing the logging system several times with several log4.properties files because each "plugin"/apache module ships with its own initialization and is unaware of the existence of the other properties file. I suppose that I'm relatively safe even when this happens. I suppose either the definitions (appenders, loggers) are merged or overwritten. After this happens, if each module has its own logger with a different name then everything should be fine. Maybe a small memory leak due to the multiple initializations, but it shouldn't be serious as it's a one-off event. Best regards, Sorin |