diff --git a/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF index bb6e4db636..a82e18fe2c 100644 --- a/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.alertviz/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.message;bundle-version="1.11.11", com.raytheon.uf.common.alertviz, javax.jms;bundle-version="1.0.0", - org.apache.log4j + org.apache.log4j, + ch.qos.logback;bundle-version="1.0.13" Bundle-ClassPath: ., lib/derbyrun.jar, lib/derby.jar @@ -29,4 +30,4 @@ Import-Package: com.raytheon.uf.common.python, com.raytheon.uf.viz.python.swt.widgets Bundle-ActivationPolicy: lazy Eclipse-BuddyPolicy: ext, registered, global -Eclipse-RegisterBuddy: org.apache.log4j +Eclipse-RegisterBuddy: ch.qos.logback, org.apache.log4j diff --git a/cave/com.raytheon.uf.viz.alertviz/logback-alertviz.xml b/cave/com.raytheon.uf.viz.alertviz/logback-alertviz.xml new file mode 100644 index 0000000000..882bf42e8c --- /dev/null +++ b/cave/com.raytheon.uf.viz.alertviz/logback-alertviz.xml @@ -0,0 +1,87 @@ + + + + + %-5p %d [%t] %c{0}: %m%n + + + INFO + + + + + System.err + + WARN + + + %-5p %d [%t] %c{0}: %m%n + + + + + + alertviz-admin.log + LOGFILE_ALERTVIZ + + alertviz-admin.log%i + LOGFILE_ALERTVIZ + 1 + 5 + + + 2GB + + true + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.base.feature/feature.xml b/cave/com.raytheon.uf.viz.base.feature/feature.xml index 5aa3cbdc9d..8d726ff05c 100644 --- a/cave/com.raytheon.uf.viz.base.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.base.feature/feature.xml @@ -247,4 +247,17 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index acf6c2f20d..095da6f847 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -41,10 +41,11 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.alertmonitor;bundle-version="1.12.1174", com.raytheon.uf.common.python;bundle-version="1.12.1174", com.raytheon.uf.common.velocity;bundle-version="1.0.0", - org.apache.log4j;bundle-version="1.0.0" + org.apache.log4j;bundle-version="1.0.0", + ch.qos.logback;bundle-version="1.0.13" Bundle-ActivationPolicy: lazy Eclipse-BuddyPolicy: ext, registered, global -Eclipse-RegisterBuddy: org.apache.velocity, org.apache.log4j, com.raytheon.edex.common, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.comm +Eclipse-RegisterBuddy: org.apache.velocity, org.apache.log4j, com.raytheon.edex.common, com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization.comm, com.raytheon.uf.common.status, com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.comm, ch.qos.logback Export-Package: com.raytheon.uf.viz.core, com.raytheon.uf.viz.core.alerts, com.raytheon.uf.viz.core.auth, @@ -68,7 +69,6 @@ Export-Package: com.raytheon.uf.viz.core, com.raytheon.uf.viz.core.legend, com.raytheon.uf.viz.core.level, com.raytheon.uf.viz.core.localization, - com.raytheon.uf.viz.core.log, com.raytheon.uf.viz.core.map, com.raytheon.uf.viz.core.notification, com.raytheon.uf.viz.core.notification.jobs, diff --git a/cave/com.raytheon.uf.viz.core/build.properties b/cave/com.raytheon.uf.viz.core/build.properties index e1ef112c75..da55604465 100644 --- a/cave/com.raytheon.uf.viz.core/build.properties +++ b/cave/com.raytheon.uf.viz.core/build.properties @@ -7,4 +7,5 @@ bin.includes = META-INF/,\ scriptTemplates/,\ schema/,\ log4j-viz-core.xml,\ - res/ + res/,\ + logback-viz-core.xml diff --git a/cave/com.raytheon.uf.viz.core/logback-viz-core-developer.xml b/cave/com.raytheon.uf.viz.core/logback-viz-core-developer.xml new file mode 100644 index 0000000000..ccd8bdb7d8 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/logback-viz-core-developer.xml @@ -0,0 +1,68 @@ + + + + %-5p %d [%t] %c{0}: %m%n + + + INFO + + + + + System.err + + WARN + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.core/logback-viz-core.xml b/cave/com.raytheon.uf.viz.core/logback-viz-core.xml new file mode 100644 index 0000000000..85395b8e59 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/logback-viz-core.xml @@ -0,0 +1,116 @@ + + + + %-5p %d [%t] %c{0}: %m%n + + + INFO + + + + + System.err + + WARN + + + %-5p %d [%t] %c{0}: %m%n + + + + + + cave-alertviz.log + + cave-alertviz.log%i + LOGFILE_CAVE + 1 + 5 + + + 2GB + + true + + %-5p %d [%t] %c{0}: %m%n + + + + + + cave-performance.log + + cave-performance.log%i + LOGFILE_PERFORMANCE + 1 + 5 + + + 2GB + + true + + %-5p %d [%t] %c{0}: %m%n + + + + + 500 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.core/res/spring/viz.xml b/cave/com.raytheon.uf.viz.core/res/spring/viz.xml index ceb8bdc277..d7b13a2cbf 100644 --- a/cave/com.raytheon.uf.viz.core/res/spring/viz.xml +++ b/cave/com.raytheon.uf.viz.core/res/spring/viz.xml @@ -32,7 +32,9 @@ - + + + + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-hibernate-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/logback-ingest.xml b/edexOsgi/build.edex/esb/conf/logback-ingest.xml new file mode 100644 index 0000000000..074c1bc98a --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/logback-ingest.xml @@ -0,0 +1,332 @@ + + + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-hibernate-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-radar-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-satellite-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-shef-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-smartInit-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-ingest-GFEPerformance-%d{yyyyMMdd}.log + 30 + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-purge-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-archive-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-unrecognized-files-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-shef-performance-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-gen_areal_ffg-%d{yyyyMMdd}.log + + + %-5p %d [%t] %c{0}: %m%n + + 30 + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-gen_areal_qpe-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-text-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-trigger-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + RadarLog:radarThreadPool.*;SatelliteLog:satelliteThreadPool.*;ShefLog:shefThreadPool.*;TextLog:textThreadPool.*;SmartInitLog:smartInit.* + asyncConsole + + + + + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-performance-%d{yyyyMMdd}.log + 30 + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/logback-registry.xml b/edexOsgi/build.edex/esb/conf/logback-registry.xml new file mode 100644 index 0000000000..53d12933a4 --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/logback-registry.xml @@ -0,0 +1,158 @@ + + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-hibernate-%d{yyyyMMdd}.log + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-harvester-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-bandwidth-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-datadelivery-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-purge-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + HarvesterLog:harvesterThreadPool.*,crawlerThreadPool.*,Crawler.* + console + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/logback.xml b/edexOsgi/build.edex/esb/conf/logback.xml new file mode 100644 index 0000000000..f125eebab2 --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/logback.xml @@ -0,0 +1,151 @@ + + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-hibernate-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + ${edex.home}/logs/edex-request-productSrvRequest-%d{yyyyMMdd}.log + 30 + + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + ${edex.home}/logs/edex-request-thriftSrv-%d{yyyyMMdd}.log + 30 + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + ${edex.home}/logs/edex-${edex.run.mode}-performance-%d{yyyyMMdd}.log + 30 + + + %-5p %d [%t] %c{0}: %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/esb/conf/logging.properties b/edexOsgi/build.edex/esb/conf/logging.properties new file mode 100644 index 0000000000..63b272246c --- /dev/null +++ b/edexOsgi/build.edex/esb/conf/logging.properties @@ -0,0 +1,3 @@ +# send any java.util.logging to SLF4J +# only thing known in the system using java.util.logging is CXF +handlers = org.slf4j.bridge.SLF4JBridgeHandler \ No newline at end of file diff --git a/edexOsgi/build.edex/esb/conf/spring/edex.xml b/edexOsgi/build.edex/esb/conf/spring/edex.xml index 546d3abf49..43a60967b3 100644 --- a/edexOsgi/build.edex/esb/conf/spring/edex.xml +++ b/edexOsgi/build.edex/esb/conf/spring/edex.xml @@ -297,7 +297,9 @@ - + + + - - - - + + diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.level/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.level/META-INF/MANIFEST.MF index d367f82e13..029e9691a9 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.level/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/META-INF/MANIFEST.MF @@ -9,7 +9,6 @@ Bundle-Vendor: Raytheon Require-Bundle: javax.measure, javax.persistence, org.apache.commons.lang, - org.apache.commons.logging, com.raytheon.uf.common.dataplugin, com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization, diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/LevelFactory.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/LevelFactory.java index 3749289c0e..35f0110d7d 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/LevelFactory.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/LevelFactory.java @@ -34,9 +34,6 @@ import javax.measure.unit.Unit; import javax.measure.unit.UnitFormat; import javax.xml.bind.JAXB; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.request.GetLevelByIdRequest; import com.raytheon.uf.common.dataplugin.level.request.GetLevelRequest; @@ -60,6 +57,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 03, 2009 rjpeter Initial creation. + * Jul 01, 2013 2142 njensen Remove apache.commons.logging * * * @author rjpeter @@ -71,14 +69,10 @@ public class LevelFactory { public static final String UNKNOWN_LEVEL = "UNKNOWN"; - private static final String LEVEL_FILENAME = "level/LevelAliases.xml"; - private static final String MASTER_LEVEL_FILENAME = "/level/masterLevels.xml"; private static LevelFactory instance = new LevelFactory(); - private Log logger = LogFactory.getLog(LevelFactory.class); - // contains the master levels private Map masterLevelCache = new HashMap(); @@ -209,7 +203,7 @@ public class LevelFactory { e.printStackTrace(); } } else { - logger.warn("Requested level name [" + name + statusHandler.warn("Requested level name [" + name + "] does not map to a defined level"); // TODO throw level exception } @@ -249,7 +243,7 @@ public class LevelFactory { cacheMasterLevel(rval); } } else { - logger.error("No level retrieval adapter defined"); + statusHandler.error("No level retrieval adapter defined"); } return rval; diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/LogRedirector.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/LogRedirector.java index c31ead432e..be089380fd 100644 --- a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/LogRedirector.java +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/LogRedirector.java @@ -23,7 +23,8 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; /** - * TODO Add Description + * Redirects geotools logs to another logging framework. Pray that someday they + * will just hook into SLF4J and save us the trouble. * *
  * 
@@ -32,6 +33,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 29, 2011            rjpeter     Initial creation
+ * Jun 27, 2013 2142       njensen     Inject factory from spring
  * 
  * 
* @@ -40,16 +42,15 @@ import com.raytheon.uf.common.status.UFStatus.Priority; */ public class LogRedirector { - private static LogRedirector instance = new LogRedirector(); - public static LogRedirector getInstance() { - return instance; + public static LogRedirector setGeotoolsLogFactory(String factoryName) { + return new LogRedirector(factoryName); } - public LogRedirector() { + private LogRedirector(String factoryName) { try { org.geotools.util.logging.Logging.GEOTOOLS - .setLoggerFactory("org.geotools.util.logging.CommonsLoggerFactory"); + .setLoggerFactory(factoryName); } catch (ClassNotFoundException e) { UFStatus.getHandler(LogRedirector.class).handle(Priority.WARN, "Failed to redirect geotools logging", e); diff --git a/edexOsgi/com.raytheon.uf.common.status/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.status/META-INF/MANIFEST.MF index cc1e82eb6b..90975efbca 100644 --- a/edexOsgi/com.raytheon.uf.common.status/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.status/META-INF/MANIFEST.MF @@ -5,6 +5,8 @@ Bundle-SymbolicName: com.raytheon.uf.common.status Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON Eclipse-BuddyPolicy: ext, registered, global +Eclipse-RegisterBuddy: ch.qos.logback Export-Package: com.raytheon.uf.common.status Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.apache.log4j;bundle-version="1.0.0" +Require-Bundle: org.slf4j;bundle-version="1.7.5", + ch.qos.logback;bundle-version="1.0.13" diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/Log4JPerformanceStatusHandler.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/Log4JPerformanceStatusHandler.java index b543997390..a81c9c26c5 100644 --- a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/Log4JPerformanceStatusHandler.java +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/Log4JPerformanceStatusHandler.java @@ -1,6 +1,7 @@ package com.raytheon.uf.common.status; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Log4j Performance status handler. @@ -21,7 +22,7 @@ import org.apache.log4j.Logger; public class Log4JPerformanceStatusHandler implements IPerformanceStatusHandler { /** Logger */ - private final Logger perfLog = Logger.getLogger("PerformanceLogger"); + private final Logger perfLog = LoggerFactory.getLogger("PerformanceLogger"); /** Prefix to append to all log messages */ private final String prefix; diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableFixedWindowRollingPolicy.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableFixedWindowRollingPolicy.java new file mode 100644 index 0000000000..b89547419f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableFixedWindowRollingPolicy.java @@ -0,0 +1,70 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.status.logback; + +import ch.qos.logback.core.rolling.FixedWindowRollingPolicy; + +/** + * Fixed window rolling policy that determines the filename pattern from an + * environment variable. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 26, 2013 2142       njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class EnvConfigurableFixedWindowRollingPolicy extends + FixedWindowRollingPolicy { + + private String envLogVar; + + /** + * @param envLogVar + * the envLogVar to set + */ + public void setEnvLogVar(String envLogVar) { + this.envLogVar = envLogVar; + setFileFromEnv(); + } + + private void setFileFromEnv() { + if (envLogVar == null || envLogVar.isEmpty()) { + this.addWarn("EnvConfigurableFixedWindowRollingPolicy requires EnvLogVar to be set."); + } else { + String file = System.getenv(envLogVar); + if (file == null || file.isEmpty()) { + this.addWarn("Appender needs environment variable, " + + envLogVar + ", to be set."); + } else { + setFileNamePattern(file + "%i"); + } + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableRollingFileAppender.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableRollingFileAppender.java new file mode 100644 index 0000000000..547ef0a60b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/EnvConfigurableRollingFileAppender.java @@ -0,0 +1,83 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.status.logback; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.rolling.RollingFileAppender; + +/** + * RollingFileAppender retrieves the value set for property EnvLogVar from the + * system environment to define the log file. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 10, 2012            bgonzale    Initial creation
+ * Mar 21, 2013 1638       mschenke    Moved from alertviz to core
+ * Jun 27, 2013 2142       njensen     Use SLF4J instead of log4j
+ * 
+ * 
+ * + * @author bgonzale + * @version 1.0 + */ + +public class EnvConfigurableRollingFileAppender extends + RollingFileAppender { + + private String envLogVar; + + /** + * @param envLogVar + * the envLogVar to set + */ + public void setEnvLogVar(String envLogVar) { + this.envLogVar = envLogVar; + setFileFromEnv(); + } + + /** + * @return the envLogVar + */ + public String getEnvLogVar() { + return envLogVar; + } + + private void setFileFromEnv() { + if (envLogVar == null || envLogVar.isEmpty()) { + this.addWarn("Appender [" + name + + "] requires EnvLogVar to be set."); + } else { + String file = System.getenv(envLogVar); + + if (file == null || file.isEmpty()) { + this.addWarn("Appender [" + name + + "] needs environment variable, " + envLogVar + + ", to be set."); + } else { + setFile(file); + } + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/InvertedThresholdFilter.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/InvertedThresholdFilter.java new file mode 100644 index 0000000000..d13fed7336 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/InvertedThresholdFilter.java @@ -0,0 +1,74 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.status.logback; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + +/** + * Filter that only allows through logging events that are equal to or below the + * set threshold level. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 26, 2013            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class InvertedThresholdFilter extends Filter { + + protected Level thresholdLevel; + + @Override + public FilterReply decide(ILoggingEvent event) { + if (!isStarted()) { + return FilterReply.NEUTRAL; + } + + int eventLevelInt = event.getLevel().toInt(); + int thresholdLevelInt = thresholdLevel.toInt(); + if (eventLevelInt <= thresholdLevelInt) { + return FilterReply.NEUTRAL; + } else { + return FilterReply.DENY; + } + } + + public void setLevel(String level) { + this.thresholdLevel = Level.toLevel(level); + } + + @Override + public void start() { + if (this.thresholdLevel != null) { + super.start(); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.log/src/com/raytheon/uf/edex/log/ThreadBasedAppender.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/ThreadBasedAppender.java similarity index 78% rename from edexOsgi/com.raytheon.uf.edex.log/src/com/raytheon/uf/edex/log/ThreadBasedAppender.java rename to edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/ThreadBasedAppender.java index 467a7cb8fa..40dca31de6 100644 --- a/edexOsgi/com.raytheon.uf.edex.log/src/com/raytheon/uf/edex/log/ThreadBasedAppender.java +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/ThreadBasedAppender.java @@ -17,27 +17,25 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.log; +package com.raytheon.uf.common.status.logback; import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Timer; import java.util.TimerTask; -import java.util.Map.Entry; import java.util.regex.Pattern; -import org.apache.log4j.Appender; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.AppenderAttachable; -import org.apache.log4j.spi.LoggingEvent; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.Appender; +import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.spi.AppenderAttachable; /** - * TODO Add Description + * Appender for logging based on the thread name of the logging event. * *
  * 
@@ -45,6 +43,7 @@ import org.apache.log4j.spi.LoggingEvent;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Aug 25, 2010            rjpeter     Initial creation
+ * Jun 24, 2013 2142       njensen     Changes for logback compatibility
  * 
  * 
* @@ -52,19 +51,19 @@ import org.apache.log4j.spi.LoggingEvent; * @version 1.0 */ -public class ThreadBasedAppender extends AppenderSkeleton implements Appender, - AppenderAttachable { - private Map appenderMap = new HashMap(); +public class ThreadBasedAppender extends + AppenderBase implements AppenderAttachable { + private Map> appenderMap = new HashMap>(); private Map> threadPatterns = new HashMap>(); - private Map threadAppenderCache = new HashMap(); + private Map> threadAppenderCache = new HashMap>(); private Map threadAppenderTimeCache = new HashMap(); private String defaultAppenderName; - private Appender defaultAppender; + private Appender defaultAppender; // keep thread names and their associated appender mapped for 10 minutes private static final long RETENTION_TIME = 1000 * 60 * 1; @@ -72,7 +71,7 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, private Timer cacheTimer; @Override - public void activateOptions() { + public void start() { if (defaultAppenderName != null) { defaultAppender = appenderMap.get(defaultAppenderName); } @@ -100,22 +99,18 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, }; cacheTimer.schedule(purgeCache, 1000, 60000); + super.start(); } @Override - public void addAppender(Appender newAppender) { + public void addAppender(Appender newAppender) { if (newAppender != null && newAppender.getName() != null) { appenderMap.put(newAppender.getName(), newAppender); } } @Override - public Enumeration getAllAppenders() { - return Collections.enumeration(appenderMap.values()); - } - - @Override - public Appender getAppender(String name) { + public Appender getAppender(String name) { if (name != null) { return appenderMap.get(name); } @@ -124,7 +119,7 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, } @Override - public boolean isAttached(Appender appender) { + public boolean isAttached(Appender appender) { if (appender != null) { return appenderMap.containsKey(appender.getName()); } @@ -133,28 +128,36 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, } @Override - public void removeAllAppenders() { + public void detachAndStopAllAppenders() { appenderMap.clear(); } @Override - public void removeAppender(Appender appender) { + public boolean detachAppender(Appender appender) { + boolean retVal = false; if (appender != null) { - appenderMap.remove(appender.getName()); + retVal = detachAppender(appender.getName()); } + return retVal; } @Override - public void removeAppender(String name) { + public boolean detachAppender(String name) { + boolean retVal = false; if (name != null) { - appenderMap.remove(name); + Appender app = appenderMap.remove(name); + if (app != null) { + retVal = true; + } } + + return retVal; } @Override - protected void append(LoggingEvent event) { + protected void append(E event) { String threadName = event.getThreadName(); - Appender app = null; + Appender app = null; app = threadAppenderCache.get(threadName); @@ -180,7 +183,7 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, synchronized (this) { // not modifiying the map directly to avoid concurrent // exceptions without forcing synchronization - Map tmp = new HashMap( + Map> tmp = new HashMap>( threadAppenderCache); tmp.put(threadName, app); threadAppenderCache = tmp; @@ -199,15 +202,6 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, } } - @Override - public void close() { - } - - @Override - public boolean requiresLayout() { - return true; - } - public void setThreadPatterns(String value) { String[] appenderPatterns = value.split("[;\n]"); for (String appenderPattern : appenderPatterns) { @@ -230,8 +224,8 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, private void removeOldEntries() { long curTime = System.currentTimeMillis(); - List keysToRemove = new ArrayList(threadAppenderCache - .size()); + List keysToRemove = new ArrayList( + threadAppenderCache.size()); for (Entry entry : threadAppenderTimeCache.entrySet()) { if (curTime - entry.getValue() > RETENTION_TIME) { @@ -245,7 +239,7 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, synchronized (this) { // not modifiying the map directly to avoid concurrent // exceptions without forcing synchronization - Map tmp = new HashMap( + Map> tmp = new HashMap>( threadAppenderCache); tmp.remove(key); threadAppenderCache = tmp; @@ -256,4 +250,9 @@ public class ThreadBasedAppender extends AppenderSkeleton implements Appender, } } } + + @Override + public Iterator> iteratorForAppenders() { + return appenderMap.values().iterator(); + } } diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/UFLogbackInternalStatusListener.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/UFLogbackInternalStatusListener.java new file mode 100644 index 0000000000..1844cbc08a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/logback/UFLogbackInternalStatusListener.java @@ -0,0 +1,51 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.status.logback; + +import ch.qos.logback.core.status.OnConsoleStatusListener; +import ch.qos.logback.core.status.Status; + +/** + * Status listener for Logback's internal status messages. Shows warnings and + * errors from logback itself to the console. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 27, 2013            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class UFLogbackInternalStatusListener extends OnConsoleStatusListener { + + public void addStatusEvent(Status status) { + if (status.getLevel() >= Status.WARN) { + super.addStatusEvent(status); + } + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml index f8dc7dba14..c79ec44b8b 100644 --- a/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml @@ -28,13 +28,6 @@ version="0.0.0" unpack="false"/> - - * @@ -44,7 +47,10 @@ import com.raytheon.uf.common.status.UFStatus.Priority; */ public class EdexLogHandler implements IUFStatusHandler { - private final Log clazzLogger; + + private static final Marker FATAL = MarkerFactory.getMarker("FATAL"); + + private final Logger clazzLogger; private final AbstractHandlerFactory factory; @@ -55,7 +61,7 @@ public class EdexLogHandler implements IUFStatusHandler { private String source; public EdexLogHandler(String clazz, String category, String source) { - this.clazzLogger = LogFactory.getLog(clazz); + this.clazzLogger = LoggerFactory.getLogger(clazz); this.pluginId = clazz; this.category = category; this.source = source; @@ -64,7 +70,7 @@ public class EdexLogHandler implements IUFStatusHandler { public EdexLogHandler(AbstractHandlerFactory factory, String pluginId, String category) { - this.clazzLogger = LogFactory.getLog(pluginId); + this.clazzLogger = LoggerFactory.getLogger(pluginId); this.pluginId = pluginId; this.category = category; this.factory = null; @@ -74,7 +80,7 @@ public class EdexLogHandler implements IUFStatusHandler { public boolean isPriorityEnabled(Priority p) { switch (p) { case CRITICAL: - return clazzLogger.isFatalEnabled(); + return true; case SIGNIFICANT: return clazzLogger.isErrorEnabled(); case PROBLEM: @@ -124,7 +130,7 @@ public class EdexLogHandler implements IUFStatusHandler { switch (p) { case CRITICAL: - clazzLogger.fatal(statusMsg, t); + clazzLogger.error(FATAL, statusMsg, t); break; case SIGNIFICANT: clazzLogger.error(statusMsg, t); @@ -179,7 +185,7 @@ public class EdexLogHandler implements IUFStatusHandler { switch (p) { case CRITICAL: - clazzLogger.fatal(msg); + clazzLogger.error(FATAL, msg); break; case SIGNIFICANT: clazzLogger.error(msg); @@ -225,7 +231,7 @@ public class EdexLogHandler implements IUFStatusHandler { switch (p) { case CRITICAL: - clazzLogger.fatal(msg, t); + clazzLogger.error(FATAL, msg, t); break; case SIGNIFICANT: clazzLogger.error(msg, t); diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.level/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.level/META-INF/MANIFEST.MF index 7687178a07..479bbe4130 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.level/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.level/META-INF/MANIFEST.MF @@ -11,10 +11,10 @@ Require-Bundle: com.raytheon.edex.common, org.eclipse.ui, org.eclipse.core.runtime, org.apache.commons.lang, - org.apache.commons.logging, com.raytheon.uf.common.localization, com.raytheon.uf.common.dataplugin.level, - com.raytheon.uf.common.serialization.comm + com.raytheon.uf.common.serialization.comm, + org.slf4j;bundle-version="1.7.5" Export-Package: com.raytheon.uf.edex.plugin.level.adapter, com.raytheon.uf.edex.plugin.level.dao Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/edexOsgi/com.raytheon.uf.edex.purgesrv/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.purgesrv/META-INF/MANIFEST.MF index 7307eecc35..f6ced155da 100644 --- a/edexOsgi/com.raytheon.uf.edex.purgesrv/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.purgesrv/META-INF/MANIFEST.MF @@ -6,7 +6,6 @@ Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.raytheon.edex.common;bundle-version="1.11.26", - org.apache.commons.logging;bundle-version="1.0.4", org.apache.commons.lang;bundle-version="2.3.0", com.raytheon.uf.common.status;bundle-version="1.12.1174", javax.persistence;bundle-version="1.0.0"