From fa1aa6a2512cfdd38edf94a2893ce67cef6d7a7a Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 3 Feb 2011 19:17:08 +0100 Subject: [PATCH] added release logging --- .../main/java/sonia/scm/util/ServiceUtil.java | 19 ++-- scm-webapp/pom.xml | 23 +++++ .../sonia/scm/ScmLogFilePropertyDefiner.java | 91 +++++++++++++++++++ .../{logback.xml => logback.default.xml} | 0 .../src/main/resources/logback.release.xml | 41 +++++++++ 5 files changed, 161 insertions(+), 13 deletions(-) create mode 100644 scm-webapp/src/main/java/sonia/scm/ScmLogFilePropertyDefiner.java rename scm-webapp/src/main/resources/{logback.xml => logback.default.xml} (100%) create mode 100644 scm-webapp/src/main/resources/logback.release.xml diff --git a/scm-core/src/main/java/sonia/scm/util/ServiceUtil.java b/scm-core/src/main/java/sonia/scm/util/ServiceUtil.java index 7b95d6d5b0..3d87256eb6 100644 --- a/scm-core/src/main/java/sonia/scm/util/ServiceUtil.java +++ b/scm-core/src/main/java/sonia/scm/util/ServiceUtil.java @@ -29,13 +29,10 @@ * */ + + package sonia.scm.util; -//~--- non-JDK imports -------------------------------------------------------- - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - //~--- JDK imports ------------------------------------------------------------ import java.util.ArrayList; @@ -50,12 +47,6 @@ import java.util.ServiceLoader; public class ServiceUtil { - /** Field description */ - private static final Logger logger = - LoggerFactory.getLogger(ServiceUtil.class); - - //~--- get methods ---------------------------------------------------------- - /** * Method description * @@ -102,7 +93,8 @@ public class ServiceUtil } catch (NoSuchElementException ex) { - logger.debug(ex.getMessage(), ex); + + // do nothing } return result; @@ -135,7 +127,8 @@ public class ServiceUtil } catch (NoSuchElementException ex) { - logger.debug(ex.getMessage(), ex); + + // do nothing } return result; diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index f1668f8746..c35cee3cde 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -198,6 +198,24 @@ + + sonia.maven + change-env + 1.0-SNAPSHOT + + ${environment.profile} + .*(\.{env})\.xml + + + + process-resources + + change-env + + + + + org.mortbay.jetty maven-jetty-plugin @@ -230,6 +248,7 @@ + default 1.9 1.0-beta-7 3.0.2 @@ -277,6 +296,10 @@ + + + release + diff --git a/scm-webapp/src/main/java/sonia/scm/ScmLogFilePropertyDefiner.java b/scm-webapp/src/main/java/sonia/scm/ScmLogFilePropertyDefiner.java new file mode 100644 index 0000000000..b0d48ff71c --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/ScmLogFilePropertyDefiner.java @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm; + +//~--- non-JDK imports -------------------------------------------------------- + +import ch.qos.logback.core.PropertyDefinerBase; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.File; + +/** + * + * @author Sebastian Sdorra + */ +public class ScmLogFilePropertyDefiner extends PropertyDefinerBase +{ + + /** Field description */ + public static final String LOG_DIRECTORY = "logs"; + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + */ + public ScmLogFilePropertyDefiner() + { + File logDirectory = new File(SCMContext.getContext().getBaseDirectory(), + LOG_DIRECTORY); + + if (!logDirectory.exists()) + { + logDirectory.mkdirs(); + } + + this.logDirectoryPath = logDirectory.getAbsolutePath(); + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + @Override + public String getPropertyValue() + { + return logDirectoryPath; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String logDirectoryPath; +} diff --git a/scm-webapp/src/main/resources/logback.xml b/scm-webapp/src/main/resources/logback.default.xml similarity index 100% rename from scm-webapp/src/main/resources/logback.xml rename to scm-webapp/src/main/resources/logback.default.xml diff --git a/scm-webapp/src/main/resources/logback.release.xml b/scm-webapp/src/main/resources/logback.release.xml new file mode 100644 index 0000000000..87549b53c8 --- /dev/null +++ b/scm-webapp/src/main/resources/logback.release.xml @@ -0,0 +1,41 @@ + + + + + + + + + + ${LOGDIR}/scm-manager.log + + + scm-manager-%i.log + 1 + 10 + + + + 10MB + + + true + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + + +