From: Sanjay Dalal Date: Wed, 3 Mar 2010 22:56:41 +0000 (+0000) Subject: CSPACE-1034 X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=f5f1d695c8795f21a0f41d4d13c6363839a1e9a5;p=tmp%2Fjakarta-migration.git CSPACE-1034 !!! requires ant clean undeploy deploy at the trunk level !!! removed log4j.properties from cspace-services.war added log4j repositoryselector to avoid jboss jamming cspace war's log st. on top of its log st. added jboss-log4j.xml to build (common/src/main/config/log), copied to jboss at deploy time, only org.collectionspace is in DEBUG cateogry, cspace/log/collectionspace.log contains cs log moved bindnigs to common/src/main/config/services removed log4j.jar from nuxeo-client/lib and from cspace-services.war removed spring's log4jconfiglistener from web.xml that was shutting down logmanager ant clean undeploy deploy at trunk level test mvn test at trunk level D trunk/services/JaxRsServiceProvider/src/main/resources/log4j.properties M trunk/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml M trunk/services/JaxRsServiceProvider/pom.xml A trunk/services/common/src/main/java/org/collectionspace/services/common/log A trunk/services/common/src/main/java/org/collectionspace/services/common/log/CollectionSpaceLog4jRepositorySelector.java M trunk/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java A trunk/services/common/src/main/config/log A trunk/services/common/src/main/config/log/jboss-log4j.xml D trunk/services/common/src/main/config/service-config.xml D trunk/services/common/src/main/config/tenant-bindings.xml A trunk/services/common/src/main/config/services A + trunk/services/common/src/main/config/services/service-config.xml A + trunk/services/common/src/main/config/services/tenant-bindings.xml M trunk/services/common/build.xml D trunk/3rdparty/nuxeo/nuxeo-client/lib/log4j.jar --- diff --git a/3rdparty/nuxeo/nuxeo-client/lib/log4j.jar b/3rdparty/nuxeo/nuxeo-client/lib/log4j.jar deleted file mode 100644 index 1183df881..000000000 Binary files a/3rdparty/nuxeo/nuxeo-client/lib/log4j.jar and /dev/null differ diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 885edabcc..879c13d48 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -20,6 +20,23 @@ 3.0.1.RELEASE + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + + log4j + log4j + 1.2.14 + provided + + org.collectionspace.services org.collectionspace.services.common @@ -117,21 +134,6 @@ test - - - - org.slf4j - slf4j-simple - test - 1.5.2 - @@ -318,7 +320,7 @@ CollectionSpace Services ${pom.groupId} ${cs.release} - + diff --git a/services/JaxRsServiceProvider/src/main/resources/log4j.properties b/services/JaxRsServiceProvider/src/main/resources/log4j.properties deleted file mode 100644 index 3d9f1a681..000000000 --- a/services/JaxRsServiceProvider/src/main/resources/log4j.properties +++ /dev/null @@ -1,24 +0,0 @@ -log4j.rootLogger=debug, stdout, R - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -# Pattern to output the caller's file name and line number. -log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.File=$jboss.home.dir/server/cspace/log/server.log - -log4j.appender.R.MaxFileSize=100KB -# Keep one backup file -log4j.appender.R.MaxBackupIndex=1 - -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n - -#packages -log4j.logger.org.jboss.resteasy=INFO -log4j.logger.org.nuxeo=WARN -log4j.logger.nuxeo=INFO -log4j.logger.org.collectionspace=DEBUG -log4j.logger.org.springframework=INFO \ No newline at end of file diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml index 13b44e412..65512963b 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml @@ -10,6 +10,12 @@ --> CollectionSpace Services + + Sets the logging context for the Tiger web-app + cspace-logging-context + CSpaceLoggingContext + java.lang.String + javax.ws.rs.Application @@ -31,19 +37,19 @@ /WEB-INF/applicationContext-security.xml - + springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy - springSecurityFilterChain - /* + springSecurityFilterChain + /* - + - org.springframework.security.web.session.HttpSessionEventPublisher + org.springframework.security.web.session.HttpSessionEventPublisher - + @@ -89,7 +95,7 @@ /* - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/common/src/main/config/service-config.xml b/services/common/src/main/config/services/service-config.xml similarity index 100% rename from services/common/src/main/config/service-config.xml rename to services/common/src/main/config/services/service-config.xml diff --git a/services/common/src/main/config/tenant-bindings.xml b/services/common/src/main/config/services/tenant-bindings.xml similarity index 100% rename from services/common/src/main/config/tenant-bindings.xml rename to services/common/src/main/config/services/tenant-bindings.xml diff --git a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java index c7e72736f..ec785541b 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java +++ b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java @@ -3,9 +3,11 @@ */ package org.collectionspace.services.common; +import org.collectionspace.services.common.log.CollectionSpaceLog4jRepositorySelector; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.apache.log4j.LogManager; /** * CollectionSpaceServiceContextListener is a ServletContextListener that helps initialize @@ -15,11 +17,18 @@ public class CollectionSpaceServiceContextListener implements ServletContextList @Override public void contextInitialized(ServletContextEvent event) { - try{ + try { ServletContext sc = event.getServletContext(); + + //create repository select to stop jboss from jamming + //our log on top of theirs + LogManager.setRepositorySelector(new CollectionSpaceLog4jRepositorySelector(), + null); + ServiceMain svcMain = ServiceMain.getInstance(); //first access initializes as well svcMain.retrieveAllWorkspaceIds(); - }catch(Exception e){ + + } catch (Exception e) { e.printStackTrace(); //fail here throw new RuntimeException(e); diff --git a/services/common/src/main/java/org/collectionspace/services/common/log/CollectionSpaceLog4jRepositorySelector.java b/services/common/src/main/java/org/collectionspace/services/common/log/CollectionSpaceLog4jRepositorySelector.java new file mode 100644 index 000000000..debb879f4 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/common/log/CollectionSpaceLog4jRepositorySelector.java @@ -0,0 +1,112 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *//** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.collectionspace.services.common.log; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.apache.log4j.Hierarchy; +import org.apache.log4j.Level; +import org.apache.log4j.spi.LoggerRepository; +import org.apache.log4j.spi.RepositorySelector; +import org.apache.log4j.spi.RootLogger; + +/** + * CollectionSpaceLog4jRepositorySelector is a CollectionSpace + * specific log4j repository selector. See Ceki's solution + * for more details + * Courtsey Ceki Gulcu http://articles.qos.ch/sc.html + */ +/** JNDI based Repository selector */ +public class CollectionSpaceLog4jRepositorySelector implements RepositorySelector { + + // key: name of logging context, + // value: Hierarchy instance + private Hashtable ht; + private Hierarchy defaultHierarchy; + + public CollectionSpaceLog4jRepositorySelector() { + ht = new Hashtable(); + defaultHierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); + } + + // the returned value is guaranteed to be non-null + public LoggerRepository getLoggerRepository() { + String loggingContextName = null; + + try { + Context ctx = new InitialContext(); + loggingContextName = (String) ctx.lookup("java:comp/env/cspace-logging-context"); + } catch (NamingException ne) { + // we can't log here + } + + if (loggingContextName == null) { + return defaultHierarchy; + } else { + Hierarchy h = (Hierarchy) ht.get(loggingContextName); + if (h == null) { + h = new Hierarchy(new RootLogger(Level.DEBUG)); + ht.put(loggingContextName, h); + } + return h; + } + } + + /** + * The Container should remove the entry when the web-application + * is removed or restarted. + * */ + public void remove(ClassLoader cl) { + ht.remove(cl); + } +}