UIMA-6109 Daemons log all classes to their log file; use a separate config file for users JD & JP logs
git-svn-id: https://svn.apache.org/repos/asf/uima/uima-ducc/trunk@1864671 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/admin/ducc_util.py b/src/main/admin/ducc_util.py
index b7f8024..3ffc538 100644
--- a/src/main/admin/ducc_util.py
+++ b/src/main/admin/ducc_util.py
@@ -1425,6 +1425,8 @@
head_ip = ducc_head
else:
head_ip = self.get_ip_address(ducc_head)
+ # Check if "reliable" ... i.e. ducc.head is the virtual ip in the keepalived conf file
+ # If so check if this node is connected to the virtual ip
if(self.is_reliable_eligible(head_ip)):
text = 'cmd: ', '/sbin/ip', 'addr', 'list'
debug(label, text)
@@ -1560,11 +1562,10 @@
if(manage_database):
dir_db_state = self.DUCC_HOME + '/state/database/'+dbhost
self.makedirs(dir_db_state)
- dir_db_logs = self.DUCC_HOME + '/logs/database/'+dbhost
+ self.db_pidfile = dir_db_state+ '/cassandra.pid'
+ dir_db_logs = self.DUCC_HOME + '/logs'
self.makedirs(dir_db_logs)
-
- self.db_pidfile = dir_db_state+ '/cassandra.pid'
- self.db_logfile = dir_db_logs + '/cassandra.console'
+ self.db_logfile = dir_db_logs + '/' + dbhost + '.cassandra.console'
self.pid_file_agents = self.DUCC_HOME + '/state/agents/ducc.pids'
self.pid_file_daemons = self.DUCC_HOME + '/state/daemons/'+self.get_node_name()+'/ducc.pids'
diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml
index c281578..c44d797 100644
--- a/src/main/resources/log4j.xml
+++ b/src/main/resources/log4j.xml
@@ -29,13 +29,6 @@
</layout>
</appender>
- <appender name="3rd-party" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %c{1} - J[%X{JID}] T[%X{TID}] %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
<appender name="jd-log" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
@@ -59,7 +52,7 @@
<appender name="system-events-log" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
<param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/system-events.log"/>
+ <param name="file" value="${DUCC_HOME}/logs/${DUCC_NODENAME}.system-events.log"/>
<param name="maxBackupIndex" value="5" />
<param name="maxFileSize" value="10MB" />
<layout class="org.apache.log4j.PatternLayout">
@@ -67,66 +60,17 @@
</layout>
</appender>
- <appender name="rmlog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
+ <!-- This should be used by all daemons -->
+ <appender name="ducc-log" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
<param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/rm.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1}- %X{JID} %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
- <appender name="orlog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/or.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - %X{JID} %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
- <appender name="smlog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/sm.log"/>
+ <param name="file" value="${DUCC_HOME}/logs/${DUCC_NODENAME}.${ducc.deploy.components}.log"/>
<param name="maxBackupIndex" value="5" />
<param name="maxFileSize" value="10MB" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - %X{JID} T[%X{TID}] %X{METHOD} %m%n"/>
</layout>
</appender>
-
- <appender name="pmlog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/pm.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - %X{JID} %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
- <appender name="wslog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/daemons/${DUCC_NODENAME}/ws.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - %X{JID} %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
- <appender name="jdout" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${ducc.process.log.dir}/jd.out.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - T[%X{TID}] %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
+
<appender name="jderr" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
<param name="append" value="true"/>
<param name="file" value="${ducc.process.log.dir}/jd.err.log"/>
@@ -137,19 +81,9 @@
</layout>
</appender>
- <appender name="agentlog" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
- <param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/agents/${DUCC_NODENAME}.${ducc.deploy.components}.log"/>
- <param name="maxBackupIndex" value="5" />
- <param name="maxFileSize" value="10MB" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - J[%X{JID}] T[%X{TID}] %X{METHOD} %m%n"/>
- </layout>
- </appender>
-
<appender name="db-loader-log" class="org.apache.uima.ducc.common.utils.DeferredOpenRollingAppender">
<param name="append" value="true"/>
- <param name="file" value="${DUCC_HOME}/logs/db.loader.log"/>
+ <param name="file" value="${DUCC_HOME}/logs/${DUCC_NODENAME}.db.loader.log"/>
<param name="maxBackupIndex" value="20" />
<param name="maxFileSize" value="20MB" />
<layout class="org.apache.log4j.PatternLayout">
@@ -164,58 +98,53 @@
<category name="org.apache.uima.ducc.rm" additivity="false">
<priority value="info"/>
- <appender-ref ref="rmlog" />
+ <appender-ref ref="ducc-log" />
</category>
<!-- Please keep these for reference as they focus on specific components of interest during debug. -->
<!-- category name="org.apache.uima.ducc.rm.JobManagerConverter" additivity="true">
<priority value="info"/>
- <appender-ref ref="rmlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.rm.NodeStability" additivity="true">
<priority value="debug"/>
- <appender-ref ref="rmlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.rm.ResourceManagerComponent" additivity="true">
<priority value="info"/>
- <appender-ref ref="rmlog" />
+ <appender-ref ref="ducc-log" />
</category -->
<category name="org.apache.uima.ducc.orchestrator" additivity="false">
<priority value="info"/>
- <appender-ref ref="orlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.agent" additivity="false">
<priority value="info"/>
- <appender-ref ref="agentlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.agent.deploy" additivity="false">
<priority value="info"/>
- <appender-ref ref="agentlog" />
- </category>
-
- <category name="org.apache.uima.ducc.jd" additivity="false">
- <priority value="info"/>
- <appender-ref ref="jdout" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.sm" additivity="false">
<priority value="info"/>
- <appender-ref ref="smlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.pm" additivity="false">
<priority value="info"/>
- <appender-ref ref="pmlog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.ws" additivity="false">
<priority value="info"/>
- <appender-ref ref="wslog" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.user.err" additivity="true">
@@ -237,12 +166,12 @@
<category name="org.apache.camel">
<priority value="warn"/>
- <appender-ref ref="3rd-party" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.camel.impl.converter">
<priority value="error"/>
- <appender-ref ref="3rd-party" />
+ <appender-ref ref="ducc-log" />
</category>
<category name="org.apache.uima.ducc.cli" additivity="false">
@@ -275,16 +204,33 @@
<appender-ref ref="db-loader-log" />
</category>
+ <!-- This is invoked from scripts, not by any of the daemons -->
+ <category name="org.apache.uima.ducc.database.lifetime" additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="console" />
+ </category>
+
+ <!-- This is invoked from scripts, not by any of the daemons -->
+ <category name="org.apache.uima.ducc.common.main" additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="console" />
+ </category>
+
<!-- This should catch the use of any DUCC classes not explicitly specified above -->
<category name="org.apache.uima.ducc" additivity="false">
<priority value="info"/>
- <appender-ref ref="console" />
+ <appender-ref ref="ducc-log" />
+ </category>
+
+ <!-- Disable the Logging initialized msgs -->
+ <category name="org.eclipse.jetty.util.log" additivity="false">
+ <priority value="warn"/>
</category>
<!-- This should be used by all non-DUCC 3rd-party code -->
<root>
<priority value = "info" />
- <appender-ref ref="3rd-party" />
+ <appender-ref ref="ducc-log" />
</root>
</log4j:configuration>
diff --git a/src/main/resources/user-log4j.xml b/src/main/resources/user-log4j.xml
new file mode 100644
index 0000000..613e003
--- /dev/null
+++ b/src/main/resources/user-log4j.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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 config file should be used by the JD and JP and log to the console -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{DATE} %5p %X{COMPONENT}.%c{1} - T[%X{TID}] %X{METHOD} %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- All DUCC classes -->
+ <category name="org.apache.uima.ducc" additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="console" />
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.springframework">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.apache.camel">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.apache.camel.impl.converter">
+ <priority value="error"/>
+ </category>
+
+ <!-- cassandra client -->
+ <category name="com.datastax.driver">
+ <priority value="warn"/>
+ </category>
+
+ <!-- Disable the Logging initialized msgs -->
+ <category name="org.eclipse.jetty.util.log" additivity="false">
+ <priority value="warn"/>
+ </category>
+
+ <!-- User code -->
+ <root>
+ <priority value = "info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
diff --git a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java
index 8e93e8f..d5514fe 100644
--- a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java
+++ b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccAdmin.java
@@ -43,6 +43,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
+import org.apache.log4j.Level;
import org.apache.uima.ducc.common.IDuccUser;
import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
import org.apache.uima.ducc.common.admin.event.DuccAdminEventKill;
@@ -146,7 +147,7 @@
public DuccLogger getLogger()
{
- return new DuccLogger("Admin");
+ return new DuccLogger(DuccAdmin.class);
}
/**
diff --git a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java
index 1046f66..50ad68f 100644
--- a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java
+++ b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/main/DuccRmAdmin.java
@@ -167,7 +167,7 @@
*/
public DuccLogger getLogger()
{
- DuccLogger ret = new DuccLogger("admin");
+ DuccLogger ret = new DuccLogger(DuccRmAdmin.class);
ret.setLevel(Level.OFF); // jrc UIMA-4358 disable logging for RM admin because
// scripting has to scrape stdout and the log gets in the way
return ret;
diff --git a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccLogger.java b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccLogger.java
index 6d2379f..226bd52 100644
--- a/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccLogger.java
+++ b/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccLogger.java
@@ -50,17 +50,21 @@
private static String daemonComponent = null;
- private static DuccLoggingThread log_thread = null;
+ //private static DuccLoggingThread log_thread = null;
private static LinkedBlockingQueue<DuccLoggingEvent> events = null;
private static AtomicBoolean threaded = new AtomicBoolean(false);
- private static boolean watchdogStarted = false;
-
+
+ // If a daemon use watchdog and configure with log4j.xml
+ // If a JD & JP which run as the user don't use watchdog and default config user-log4j.xml
+ private static boolean isJob = System.getProperty("ducc.deploy.JobDirectory") != null;
+ private static boolean watchdogStarted = isJob;
+
private final static String DEFAULT_COMPONENT = "DUCC";
private static List<Logger> nonDuccLoggers = new ArrayList<Logger>();
private boolean debug = System.getProperty("log4j.debug") != null; // Use the log4j debugging flag
- static synchronized protected void initLogger()
+/* static synchronized protected void initLogger()
{
if ( log_thread == null ) {
events = new LinkedBlockingQueue<DuccLoggingEvent>();
@@ -69,7 +73,7 @@
log_thread.setDaemon(true);
log_thread.start();
}
- }
+ }*/
static public void setDaemonComponent(String value) {
daemonComponent = value;
@@ -176,13 +180,21 @@
public DuccLogger(String claz, String requestComponent)
{
// initLogger();
-
// UIMA-4186, use log4j API for configuration
String ducc_home = System.getProperty("DUCC_HOME");
if ( ducc_home == null ) {
System.out.println("WARNING: Cannot find system property DUCC_HOME to configure ducc logger. Using default log4j configurator.");
} else {
- if ( ! watchdogStarted ) {
+ if (isJob) {
+ // Set a default configuration for JD & JP if none provided
+ String usersValue = System.getProperty("log4j.configuration");
+ if (usersValue == null) {
+ usersValue = "file:" + System.getProperty("DUCC_HOME") + "/resources/user-log4j.xml";
+ System.setProperty("log4j.configuration", usersValue);
+ }
+ isJob = false; // No need to check again
+ }
+ if ( !watchdogStarted ) {
// Explicitly set the config file since the search for the default uses
// ClassLoader.getSystemResource() so may find one in the user's classpath
// UIMA-5183 First check for a node-specific configuration file
@@ -196,7 +208,8 @@
System.out.println("DuccLogger will use configuration file: " + configFile);
}
}
- String usersValue = System.setProperty("log4j.configuration", "file:" + configFile);
+ // Change the system property, configure, and then restore any users value
+ String usersValue = System.setProperty("log4j.configuration", "file:" + configFile);
DOMConfigurator.configureAndWatch(configFile);
if (usersValue == null) {
System.clearProperty("log4j.configuration");
@@ -214,7 +227,7 @@
ErrorHandler errHandler = new DuccLogErrorHandler(this);
@SuppressWarnings("rawtypes")
- Enumeration appenders = logger.getAllAppenders();
+ Enumeration appenders = logger.getAllAppenders();
while (appenders.hasMoreElements() ) {
Appender app = (Appender) appenders.nextElement();
app.setErrorHandler(errHandler);
@@ -674,7 +687,7 @@
}
}
- static class DuccLoggingThread
+ /* static class DuccLoggingThread
extends Thread
{
public void run()
@@ -694,7 +707,7 @@
}
}
}
-
+*/
static class DuccLogErrorHandler
implements ErrorHandler
{
diff --git a/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServer.java b/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServer.java
index b3dced5..27ecbe0 100644
--- a/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServer.java
+++ b/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServer.java
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Properties;
-import org.apache.jasper.servlet.JspServlet;
import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.SimpleInstanceManager;
import org.apache.tomcat.util.scan.StandardJarScanner;
@@ -36,9 +35,9 @@
import org.apache.uima.ducc.common.internationalization.Messages;
import org.apache.uima.ducc.common.utils.DuccLogger;
import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
+import org.apache.uima.ducc.common.utils.InetHelper;
import org.apache.uima.ducc.common.utils.id.DuccId;
import org.apache.uima.ducc.ws.DuccPlugins;
-import org.eclipse.jetty.annotations.ServletContainerInitializersStarter;
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
import org.eclipse.jetty.jsp.JettyJspServlet;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
@@ -369,7 +368,9 @@
if(requestLogRetainDays > 0) {
String requestLogTimeZone = "GMT";
String requestLogFmt = "yyyy_MM_dd";
- String requestLogFile = DuccWebServerHelper.getDuccWebLogsDir()+requestLogFmt+".request.log";
+ // Put request log in shared logs/webserver dir with host as part of the filename
+ String fname = InetHelper.getHostName() + "." + requestLogFmt + ".request.log";
+ String requestLogFile = DuccWebServerHelper.getDuccWebLogsDir() + fname;
NCSARequestLog requestLog = new NCSARequestLog();
requestLog.setFilename(requestLogFile);
requestLog.setFilenameDateFormat(requestLogFmt);
diff --git a/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServerHelper.java b/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServerHelper.java
index 23327b1..ca0802b 100644
--- a/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServerHelper.java
+++ b/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebServerHelper.java
@@ -26,7 +26,6 @@
import org.apache.uima.ducc.common.IDuccEnv;
import org.apache.uima.ducc.common.utils.DuccLogger;
-import org.apache.uima.ducc.common.utils.InetHelper;
import org.apache.uima.ducc.common.utils.id.DuccId;
import org.apache.uima.ducc.ws.standardize.WsStandardize;
@@ -37,8 +36,7 @@
private static DuccId jobid = null;
public static String getDuccWebLogsDir() {
- String hostname = InetHelper.getHostName();
- String retVal = IDuccEnv.DUCC_LOGS_DIR+"daemons"+File.separator+hostname+File.separator+"webserver"+File.separator;
+ String retVal = IDuccEnv.DUCC_LOGS_DIR + "webserver " + File.separator;
return retVal;
}