Quoting jan_bar <[EMAIL PROTECTED]>: > Thanks for your extensive answer, see inline.. > > > Well, when you are using a repository selector, the idea is that you > > have Log4j in a position where it is not part of your app, but part > > of the server; otherwise there's no point to using a repository > > selector. In order for a server wide instance of Log4j to service > > many apps without each of them stomping on each other's logging, each > > app needs to be assigned its own logger repository. On the other > > hand, if you deploy your app with Log4j in WEB-INF/lib (and use > > child-first classloading behavior), you can just use the default > > logger repository since your app will be the only one utilizing the > > instance of Log4j. > > I know about this possibility and also it's classloading order fragility. I > want to avoid this. >
Don't we all. But in order to do so, we must take the necessary steps to get the custom repository selector and log4j.jar in the same classloader that is a parent of any specific application classloader. > > The solution is to deploy your custom repository selector alongside > > the global instance of Log4j, not with your app. And if you have > > access to the JBoss startup script, you can set the -D property to > > set the repository selector when JBoss starts up (sorry, can't recall > > the system property name to set ATM). > > How can I set the repository selector of JBoss startup? Is the mentioned > property used in Log4j init or inside JBoss? I looked into sources of both, > but did not found any call to LogManager.setRepositorySelector(). > My memory slightly failed me. The system property I referred to does exist, but only in Log4j-1.3alpha. You'd use either... -Dlog4j.repositorySelector=JNDI OR -Dlog4j.repositorySelector=fully.qualified.ClassName The "JNDI" value corresponds to the new org.apache.log4j.selector.ContextJNDISelector that is part of Log4j-1.3alpha, but does *not* exist in Log4j-1.2.xx. So, if you want to use this feature, you'll have to use Log4j-1.3. I would build from source if you do, because a lot has changed since the last release. A new release should be out pretty soon based on what some of the other Log4j committers have stated. Can't promise any specific date, though. > I found org.jboss.portal.common.logging.LoaderRepositorySelector, which > looks exactly as something I miss in JBoss AS. It's part of the JBoss > Portal. > So, the portal sets its own repository selector. Not sure where, but since the portal pretty much is the server to all the other portlet applications that get deployed under it, it would make sense to do it at that level. For JBoss AS, you can write a server startup class (most servers provide a proprietary API for startup classes that the server will call as configured) and set your preferred repository selector inside that. Any app deployed under that server will log to the appropriate logger repository provided by the configured repository selector. Jake > Thanks, Jan > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]