diff --git a/javaUtilities/com.raytheon.uf.logsrv/META-INF/MANIFEST.MF b/javaUtilities/com.raytheon.uf.logsrv/META-INF/MANIFEST.MF index b48d5ea02d..1cfe58ea05 100644 --- a/javaUtilities/com.raytheon.uf.logsrv/META-INF/MANIFEST.MF +++ b/javaUtilities/com.raytheon.uf.logsrv/META-INF/MANIFEST.MF @@ -1,9 +1,10 @@ Manifest-Version: 1.0 +Main-Class: com.raytheon.uf.logsrv.LogService +Class-Path: logback-core-1.0.13.jar logback-classic-1.0.13.jar derby.jar mail.jar slf4j-api-1.7.5.jar quartz-1.8.6.jar commons-lang-2.3.jar Bundle-ManifestVersion: 2 Bundle-Name: Logsrv Bundle-SymbolicName: com.raytheon.uf.logsrv -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: com.raytheon.uf.logsrv.Activator +Bundle-Version: 1.14.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy diff --git a/javaUtilities/com.raytheon.uf.logsrv/README.txt b/javaUtilities/com.raytheon.uf.logsrv/README.txt new file mode 100644 index 0000000000..9de747f42d --- /dev/null +++ b/javaUtilities/com.raytheon.uf.logsrv/README.txt @@ -0,0 +1,118 @@ +## +# 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. +## + + + +Build instructions +----------------------- +In Eclipse run the build.xml by right clicking on the build.xml file and +running it. That will produce a tar.gz with everything you need inside of it. + + +Install instructions +----------------------- +Place the tar.gz file where you would like to install it, and run tar -xvf on +the tar.gz file. Next go into the conf directory and modify config.xml to + the best settings for your cluster. Then open receiver.xml and go to the + bottom of the file. Edit the address to the name of the machine where + you are installing the log service, and pick a port if you are not happy with + the default. Once your config settings are right, run the bin/logsrv.sh + script to start the log service. + + At this point the log service is running but nothing is reporting to it. You + can configure any Java process using logback to report to it, but with the + current version that is just EDEX and CAVE. (Note technically you could + configure AlertViz to report to the service too, but that is fairly pointless). + + To configure EDEX or CAVE to report to the log service, find the logback + config files for those applications. In EDEX they can typically be found at + /awips2/edex/conf. If you are not sure which logback file corresponds to + which JVM, look at the shell scripts in /awips2/edex/etc. If not explicitly + stated in their corresponding shell script, then the JVMs use the logback file + specified in default.sh. + + In CAVE the logback config files can typically be found at + /awips2/cave/plugins/com.raytheon.uf.viz.core_${VERSION}. + + Once found, use a text editor to open the logback config file corresponding + to the process you wish to report to the log service. You need to add two + things to the file, an appender and an appender-ref. + + Add an appender like the example below in the appenders section (generally + towards the top of the file): + + + false + 5477 + dev33.oma.us.ray.com + + WARN + + + + Replace the remoteHost address with the machine where you installed the + log service. Note that you must have a network route between the two machines + as it uses a socket to report the errors. Replace the port with the port you chose + in receiver.xml. You can alter the threshold if need be. + + Next you must add your new remoteLogSrv appender to a logger. Note that a + logger can have multiple appenders. For EDEX, the recommendation is to add + it to the root logger. For example: + + + + + + + + For CAVE, the recommendation is to add it to the CaveLogger. For example: + + + + + + + +Once you save the modified logback config file, you're done. Logback will +automatically pick up a changed configuration within a minute or two, and +the Java processes you configured will start appending to the socket. + + +How it works +-------------- +The log service is listening on the socket and will store the messages in a +derby database on the filesystem, and then at the scheduled time it will +attempt to analyze and consolidate the errors based on the information it has +available. Then it will send an email using the configuration, reporting in an order +of what errors it thinks are most significant. + +Note that it does not matter if the Java processes have the socket appender +configured but the log service is not running. They will try to connect but then +go back to normal logging. If the log service is running, they will resume sending +log messages through the socket. Therefore, it does not hurt to have +everything configured even if the log service or the reporting processes are not +running. + + +Bugs and/or Improvements +-------------- +If you encounter a bug with the log service or have an idea of how it can be +improved, send an email to nathan.jensen@raytheon.com. + diff --git a/javaUtilities/com.raytheon.uf.logsrv/build.xml b/javaUtilities/com.raytheon.uf.logsrv/build.xml new file mode 100644 index 0000000000..228ec71040 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.logsrv/build.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/javaUtilities/com.raytheon.uf.logsrv/conf/config.xml b/javaUtilities/com.raytheon.uf.logsrv/conf/config.xml new file mode 100644 index 0000000000..040c26a685 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.logsrv/conf/config.xml @@ -0,0 +1,30 @@ + + + + + ec-oma + + + /common/njensen/logsrv/ + + + Nathan.Jensen@raytheon.com + mk2-msg10.raymail.ray.com + 143 + + + awipsctl@list.app.ray.com, awipstest@list.app.ray.com, david_j_hladky@raytheon.com + + + 00:45 + + + shefThreadPool + + \ No newline at end of file diff --git a/javaUtilities/com.raytheon.uf.logsrv/receiver.xml b/javaUtilities/com.raytheon.uf.logsrv/conf/receiver.xml similarity index 93% rename from javaUtilities/com.raytheon.uf.logsrv/receiver.xml rename to javaUtilities/com.raytheon.uf.logsrv/conf/receiver.xml index 478777db3c..985a8152e9 100644 --- a/javaUtilities/com.raytheon.uf.logsrv/receiver.xml +++ b/javaUtilities/com.raytheon.uf.logsrv/conf/receiver.xml @@ -5,8 +5,8 @@ - /home/njensen/logs/logService-internal-%d{yyyyMMdd}.log - 30 + ${logSrvLogs}/logs/logService-internal-%d{yyyyMMdd}.log + 7 %-5p %d [%t] %c{0}: %m%n diff --git a/javaUtilities/com.raytheon.uf.logsrv/config.xml b/javaUtilities/com.raytheon.uf.logsrv/config.xml deleted file mode 100644 index d647afea32..0000000000 --- a/javaUtilities/com.raytheon.uf.logsrv/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - ec-oma - /awips2/edex/data/utility/nate - Nathan.Jensen@raytheon.com - mk2-msg10.raymail.ray.com - 143 - awipsctl@list.app.ray.com, awipstest@list.app.ray.com, david_j_hladky@raytheon.com - - 00:45 - shefThreadPool - \ No newline at end of file diff --git a/javaUtilities/com.raytheon.uf.logsrv/logsrv.sh b/javaUtilities/com.raytheon.uf.logsrv/logsrv.sh new file mode 100644 index 0000000000..6e3cbf4a25 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.logsrv/logsrv.sh @@ -0,0 +1,29 @@ +#!/bin/bash +## +# 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. +## + + +path_to_script=`readlink -f $0` +binDir=$(dirname $path_to_script) +logSrvDir=$(dirname $binDir) +export logSrvConf=$logSrvDir/conf/ +export logSrvLogs=$logSrvDir/logs/ + +java -jar ${logSrvDir}/lib/com.raytheon.uf.logsrv.jar \ No newline at end of file diff --git a/javaUtilities/com.raytheon.uf.logsrv/src/com/raytheon/uf/logsrv/LogService.java b/javaUtilities/com.raytheon.uf.logsrv/src/com/raytheon/uf/logsrv/LogService.java index d36372a456..b68609bf77 100644 --- a/javaUtilities/com.raytheon.uf.logsrv/src/com/raytheon/uf/logsrv/LogService.java +++ b/javaUtilities/com.raytheon.uf.logsrv/src/com/raytheon/uf/logsrv/LogService.java @@ -58,6 +58,8 @@ public class LogService { private static final String SERVICE_CONFIG = "config.xml"; + private static final String ENV_CONF_DIR = "logSrvConf"; + private static final Logger logger = LoggerFactory .getLogger("InternalLogger"); @@ -67,11 +69,17 @@ public class LogService { */ public static void main(String[] args) throws Exception { logger.info("Starting log analytics service"); + String confDir = System.getenv(ENV_CONF_DIR); + if (confDir == null) { + throw new LogServiceException("Environment variable " + + ENV_CONF_DIR + + " is not set! Unable to find configuration!"); + } JAXBContext context = JAXBContext.newInstance(LogSrvConfig.class); Unmarshaller m = context.createUnmarshaller(); - LogSrvConfig config = (LogSrvConfig) m.unmarshal(new File( - SERVICE_CONFIG)); + LogSrvConfig config = (LogSrvConfig) m.unmarshal(new File(confDir + + SERVICE_CONFIG)); config.validate(); DerbyDao.getInstance().setConfig(config); logger.info("Logging events from " + config.getClusterName()); @@ -81,7 +89,7 @@ public class LogService { lc.reset(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(lc); - configurator.doConfigure(LOGBACK_CONFIG); + configurator.doConfigure(confDir + LOGBACK_CONFIG); logger.info("Scheduling report generation"); JobScheduler.scheduleJobs(config);