From: <ma...@rh...> - 2008-12-01 06:38:01
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [2146] [RHQ-1198] be ablel to change agent's log4j config at runtime.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>2146</dd> <dt>Author</dt> <dd>mazz</dd> <dt>Date</dt> <dd>2008-12-01 00:37:57 -0600 (Mon, 01 Dec 2008)</dd> </dl> <h3>Log Message</h3> <pre>[RHQ-1198] be ablel to change agent's log4j config at runtime. can also turn on and off agent-server comm tracing at runtime too. prompt command provides this at console. can add mbean access/rhq-plugin operations later</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentAgentMainjava">rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagenti18nAgentI18NResourceKeysjava">rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainresourceslog4jxml">rhq/trunk/modules/enterprise/agent/src/main/resources/log4j.xml</a></li> <li><a href="#rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationsutilCommandTraceUtiljava">rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/CommandTraceUtil.java</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentpromptcmdDebugPromptCommandjava">rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DebugPromptCommand.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainresourceslog4jwarnxml">rhq/trunk/modules/enterprise/agent/src/main/resources/log4j-warn.xml</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentAgentMainjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java (2145 => 2146)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java 2008-12-01 05:07:27 UTC (rev 2145) +++ rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -26,6 +26,7 @@ </span><span class="cx"> import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; </span><span class="add">+import java.io.FileNotFoundException; </span><span class="cx"> import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; </span><span class="lines">@@ -37,6 +38,7 @@ </span><span class="cx"> import java.lang.management.ManagementFactory; import java.lang.reflect.Method; import java.net.InetAddress; </span><span class="add">+import java.net.URL; </span><span class="cx"> import java.util.ArrayList; import java.util.Arrays; import java.util.Date; </span><span class="lines">@@ -58,6 +60,10 @@ </span><span class="cx"> import mazz.i18n.Logger; import mazz.i18n.Msg; </span><span class="add">+import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.apache.log4j.xml.DOMConfigurator; + </span><span class="cx"> import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.security.SSLSocketBuilder; </span><span class="lines">@@ -95,6 +101,7 @@ </span><span class="cx"> import org.rhq.enterprise.agent.promptcmd.AgentPromptCommand; import org.rhq.enterprise.agent.promptcmd.AvailabilityPromptCommand; import org.rhq.enterprise.agent.promptcmd.ConfigPromptCommand; </span><span class="add">+import org.rhq.enterprise.agent.promptcmd.DebugPromptCommand; </span><span class="cx"> import org.rhq.enterprise.agent.promptcmd.DiscoveryPromptCommand; import org.rhq.enterprise.agent.promptcmd.DownloadPromptCommand; import org.rhq.enterprise.agent.promptcmd.DumpSpoolPromptCommand; </span><span class="lines">@@ -134,9 +141,12 @@ </span><span class="cx"> import org.rhq.enterprise.communications.command.client.ClientRemotePojoFactory; import org.rhq.enterprise.communications.command.client.CommandPreprocessor; import org.rhq.enterprise.communications.command.client.JBossRemotingRemoteCommunicator; </span><span class="add">+import org.rhq.enterprise.communications.command.client.OutgoingCommandTrace; </span><span class="cx"> import org.rhq.enterprise.communications.command.client.RemoteCommunicator; import org.rhq.enterprise.communications.command.impl.remotepojo.RemotePojoInvocationCommand; import org.rhq.enterprise.communications.command.server.CommandListener; </span><span class="add">+import org.rhq.enterprise.communications.command.server.IncomingCommandTrace; +import org.rhq.enterprise.communications.util.CommandTraceUtil; </span><span class="cx"> import org.rhq.enterprise.communications.util.SecurityUtil; import org.rhq.enterprise.communications.util.prefs.PromptInput; </span><span class="lines">@@ -790,6 +800,71 @@ </span><span class="cx"> } /** </span><span class="add">+ * This will enable/disable agent-server communication tracing. This is for + * use mainly in development but can also be used for troubleshooting problems. + * + * @param enabled whether or not to turn on agent comm tracing + */ + public void agentServerCommunicationsTrace(boolean enabled) { + org.apache.log4j.Logger outLogger = LogManager.getLogger(OutgoingCommandTrace.class); + org.apache.log4j.Logger inLogger = LogManager.getLogger(IncomingCommandTrace.class); + Level newLevel = (enabled) ? Level.TRACE : Level.OFF; + + // set it up so the trace is more detailed, but don't override any properties already set + if (enabled) { + if (CommandTraceUtil.getSettingTraceCommandConfig() == null) { + CommandTraceUtil.setSettingTraceCommandConfig(Boolean.TRUE); + } + if (CommandTraceUtil.getSettingTraceCommandResponseResults() == null) { + CommandTraceUtil.setSettingTraceCommandResponseResults(Integer.valueOf(256)); + } + if (CommandTraceUtil.getSettingTraceCommandSizeThreshold() == null) { + CommandTraceUtil.setSettingTraceCommandSizeThreshold(Integer.valueOf(99999)); + } + if (CommandTraceUtil.getSettingTraceCommandResponseSizeThreshold() == null) { + CommandTraceUtil.setSettingTraceCommandResponseSizeThreshold(Integer.valueOf(99999)); + } + } + + outLogger.setLevel(newLevel); + inLogger.setLevel(newLevel); + } + + /** + * This will hot-deploy a new log4j log configuration file. Use this to change, at runtime, + * the log settings so you can, for example, begin logging DEBUG messages to help troubleshoot + * problems. + * + * @param logFilePath the path to the log file - relative to the classloader or filesystem + * + * @throws Exception if failed to hot deploy the new log config + */ + public void hotDeployLogConfigurationFile(String logFilePath) throws Exception { + URL logFileUrl; + + // the logfile is probably in classpath, check there first; if not, assume its on the filesystem + logFileUrl = getClass().getClassLoader().getResource(logFilePath); + if (logFileUrl == null) { + File file = new File(logFilePath); + if (!file.exists()) { + throw new FileNotFoundException(logFilePath); + } + logFileUrl = file.toURI().toURL(); + } + + try { + LogManager.resetConfiguration(); + DOMConfigurator.configure(logFileUrl); + } catch (Exception e) { + // something bad happened, let's load the file we know we have in the agent jar + hotDeployLogConfigurationFile("log4j-debug.xml"); + throw e; + } + + return; + } + + /** </span><span class="cx"> * Returns an iteratable list of servers that can be used as backups when this agent needs to failover * to another server. * </span><span class="lines">@@ -2660,7 +2735,7 @@ </span><span class="cx"> new AvailabilityPromptCommand(), new PiqlPromptCommand(), new IdentifyPromptCommand(), new LogPromptCommand(), new TimerPromptCommand(), new PingPromptCommand(), new DownloadPromptCommand(), new DumpSpoolPromptCommand(), new SenderPromptCommand(), new FailoverPromptCommand(), </span><span class="rem">- new UpdatePromptCommand() }; </span><span class="add">+ new UpdatePromptCommand(), new DebugPromptCommand() }; </span><span class="cx"> // hold the conflicts StringBuilder conflicts = new StringBuilder(); </span></pre></div> <a id="rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagenti18nAgentI18NResourceKeysjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java (2145 => 2146)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java 2008-12-01 05:07:27 UTC (rev 2145) +++ rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -655,6 +655,44 @@ </span><span class="cx"> @I18NMessage("An error occurred during shutdown. Cause: {0}") String EXIT_SHUTDOWN_ERROR = "PromptCommand.exit.shutdown-error"; </span><span class="add">+ @I18NMessage("debug") + String DEBUG = "PromptCommand.debug"; + + @I18NMessage("debug [--file=<logfile>] [--comm=true|false]") + String DEBUG_SYNTAX = "PromptCommand.debug.syntax"; + + @I18NMessage("Provides features to help debug the agent.") + String DEBUG_HELP = "PromptCommand.debug.help"; + + @I18NMessage("Provides features to help debug the agent.\\n\\\n" + + "-c|--comm=true|false: enables or disables server-agent communications trace.\\n\\\n" + + "-f|--file=<logfile>: reconfigures the logging system with the given file.\\n\\\n" + + "\\ Typically, <logfile> can be 'log4j.xml'\\n\\\n" + + "\\ 'log4j-debug.xml', but you can use your own by\\n\\\n" + + "\\ placing your log files in the /conf directory.\\n\\\n") + String DEBUG_DETAILED_HELP = "PromptCommand.debug.detailed-help"; + + @I18NMessage("Switched to log file [{0}]. Root log level is [{1}]") + String DEBUG_LOG_FILE_LOADED = "PromptCommand.debug.log-file-loaded"; + + @I18NMessage("Cannot load log file [{0}]. Cause: {1}") + String DEBUG_CANNOT_LOAD_LOG_FILE = "PromptCommand.debug.cannot-load-log-file"; + + @I18NMessage("Agent-server communications tracing has been enabled.\\n\\\n" + + "You may set the following, additional configuration settings\\n\\\n" + + "to collect more detailed trace data. You can set these\\n\\\n" + + "using the 'setconfig' prompt command. Please refer to the\\n\\\n" + + "documentation for more information on these settings. The\\n\\\n" + + "values you see here are the current settings:\\n\\\n" // + + "\\ rhq.trace-command-config={0}\\n\\\n" // + + "\\ rhq.trace-command-response-results={1,number,#}\\n\\\n" // + + "\\ rhq.trace-command-size-threshold={2,number,#}\\n\\\n" // + + "\\ rhq.trace-command-response-size-threshold={3,number,#}") + String DEBUG_CMD_TRACING_ENABLED = "PromptCommand.debug.cmd-tracing-enabled"; + + @I18NMessage("Agent-server communications tracing has been disabled.") + String DEBUG_CMD_TRACING_DISABLED = "PromptCommand.debug.cmd-tracing-disabled"; + </span><span class="cx"> @I18NMessage("failover") String FAILOVER = "PromptCommand.failover"; </span></pre></div> <a id="rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentpromptcmdDebugPromptCommandjava"></a> <div class="addfile"><h4>Added: rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DebugPromptCommand.java (0 => 2146)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DebugPromptCommand.java (rev 0) +++ rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DebugPromptCommand.java 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -0,0 +1,142 @@ </span><span class="add">+/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.agent.promptcmd; + +import gnu.getopt.Getopt; +import gnu.getopt.LongOpt; + +import java.io.PrintWriter; + +import mazz.i18n.Msg; + +import org.apache.log4j.LogManager; + +import org.rhq.core.util.exception.ThrowableUtil; +import org.rhq.enterprise.agent.AgentMain; +import org.rhq.enterprise.agent.i18n.AgentI18NFactory; +import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys; +import org.rhq.enterprise.communications.util.CommandTraceUtil; + +/** + * Performs various things to help debug the agent. + * + * @author John Mazzitelli + */ +public class DebugPromptCommand implements AgentPromptCommand { + + private static final Msg MSG = AgentI18NFactory.getMsg(); + + /** + * @see AgentPromptCommand#getPromptCommandString() + */ + public String getPromptCommandString() { + return MSG.getMsg(AgentI18NResourceKeys.DEBUG); + } + + /** + * @see AgentPromptCommand#execute(AgentMain, String[]) + */ + public boolean execute(AgentMain agent, String[] args) { + processArguments(agent, args); + return true; + } + + /** + * @see AgentPromptCommand#getSyntax() + */ + public String getSyntax() { + return MSG.getMsg(AgentI18NResourceKeys.DEBUG_SYNTAX); + } + + /** + * @see AgentPromptCommand#getHelp() + */ + public String getHelp() { + return MSG.getMsg(AgentI18NResourceKeys.DEBUG_HELP); + } + + /** + * @see AgentPromptCommand#getDetailedHelp() + */ + public String getDetailedHelp() { + return MSG.getMsg(AgentI18NResourceKeys.DEBUG_DETAILED_HELP); + } + + private void processArguments(AgentMain agent, String[] args) { + PrintWriter out = agent.getOut(); + + if (args.length <= 1) { + out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax())); + return; + } + + String sopts = "c:f:"; + LongOpt[] lopts = { new LongOpt("comm", LongOpt.REQUIRED_ARGUMENT, null, 'c'), // trace comm messages + new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f') }; // reconfigure with new log file + + Getopt getopt = new Getopt(getPromptCommandString(), args, sopts, lopts); + int code; + + while ((code = getopt.getopt()) != -1) { + switch (code) { + case ':': + case '?': + case 1: { + out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax())); + break; + } + + case 'c': { + String flag = getopt.getOptarg(); + boolean flagBoolean = Boolean.parseBoolean(flag); + agent.agentServerCommunicationsTrace(flagBoolean); + if (flagBoolean) { + out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CMD_TRACING_ENABLED, // + CommandTraceUtil.getSettingTraceCommandConfig(), // + CommandTraceUtil.getSettingTraceCommandResponseResults(), // + CommandTraceUtil.getSettingTraceCommandSizeThreshold(), // + CommandTraceUtil.getSettingTraceCommandResponseSizeThreshold())); + } else { + out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CMD_TRACING_DISABLED)); + } + break; + } + + case 'f': { + String file = getopt.getOptarg(); + try { + agent.hotDeployLogConfigurationFile(file); + out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_LOG_FILE_LOADED, file, LogManager + .getRootLogger().getLevel())); + } catch (Exception e) { + out.println(MSG.getMsg(AgentI18NResourceKeys.DEBUG_CANNOT_LOAD_LOG_FILE, file, ThrowableUtil + .getAllMessages(e))); + } + break; + } + } + } + + if ((getopt.getOptind() + 1) < args.length) { + out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax())); + } + + return; + } +} </span><span class="cx">Property changes on: rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DebugPromptCommand.java ___________________________________________________________________ </span></pre></div> <a id="svnmimetype"></a> <div class="addfile"><h4>Added: svn:mime-type ( => )</h4> <pre class="diff"> <span class="info">Added: svn:keywords + Date Author Id Revision HeadURL </span></pre></div> <a id="svneolstyle"></a> <div class="addfile"><h4>Added: svn:eol-style ( => )</h4> <pre class="diff"> <span class="info"> Added: rhq/trunk/modules/enterprise/agent/src/main/resources/log4j-warn.xml </span><span class="cx">=================================================================== </span><span class="rem">--- rhq/trunk/modules/enterprise/agent/src/main/resources/log4j-warn.xml (rev 0) </span><span class="add">+++ rhq/trunk/modules/enterprise/agent/src/main/resources/log4j-warn.xml 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -0,0 +1,99 @@ </span><span class="add">+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> + + <!-- ============================== --> + <!-- Append messages to the console --> + <!-- ============================== --> + + <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> + <param name="Threshold" value="DEBUG"/> + <param name="Target" value="System.out"/> + + <layout class="org.apache.log4j.PatternLayout"> + <!-- The default pattern: Date Priority [Category] Message\n --> + <param name="ConversionPattern" value="%d{ISO8601} %-5p [%t] (%c{5}) - %m%n"/> + </layout> + </appender> + + <!-- ================================= --> + <!-- Append messages to a rolling file --> + <!-- ================================= --> + <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> + + <param name="Threshold" value="DEBUG"/> + <param name="File" value="logs/agent.log"/> + <param name="MaxBackupIndex" value="2"/> + <param name="MaxFileSize" value="5000KB"/> + <param name="Append" value="true"/> + + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d{ISO8601} %-5p [%t] (%c{5})- %m%n"/> + </layout> + + </appender> + + <!-- ====================================== --> + <!-- Append command trace to a rolling file --> + <!-- ====================================== --> + <appender name="COMMANDTRACE" class="org.apache.log4j.RollingFileAppender"> + + <param name="Threshold" value="TRACE"/> + <param name="File" value="logs/command-trace.log"/> + <param name="MaxBackupIndex" value="9"/> + <param name="MaxFileSize" value="10MB"/> + <param name="Append" value="true"/> + + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d{MMM-dd HH:mm:ss,SSS} %m%n"/> + </layout> + + </appender> + + <!-- ================ --> + <!-- Limit categories --> + <!-- ================ --> + + <!-- RHQ --> + <category name="org.rhq"> + <priority value="WARN"/> + </category> + + <!-- RHQ outgoing command tracing - set to TRACE to trace commands sent by the agent --> + <category name="org.rhq.enterprise.communications.command.client.OutgoingCommandTrace"> + <priority value="NONE"/> + <appender-ref ref="COMMANDTRACE"/> + </category> + + <!-- RHQ incoming command tracing - set to TRACE to trace commands coming in from the Server --> + <category name="org.rhq.enterprise.communications.command.server.IncomingCommandTrace"> + <priority value="NONE"/> + <appender-ref ref="COMMANDTRACE"/> + </category> + + <!-- JBoss/Remoting - for low level communications layer tracing --> + <!-- + <category name="org.jboss.remoting"> + <priority value="TRACE" class="org.jboss.logging.XLevel"/> + </category> + --> + + <!-- EMS can be noisy with its WARN messages - uncomment the below to suppress them. --> + <!-- + <category name="org.mc4j.ems"> + <priority value="ERROR"/> + </category> + --> + + <!-- ======================= --> + <!-- Setup the Root category --> + <!-- ======================= --> + + <root> + <priority value="WARN"/> + <appender-ref ref="FILE"/> + <!-- <appender-ref ref="CONSOLE"/> --> + </root> + +</log4j:configuration> </span></pre></div> <a id="rhqtrunkmodulesenterpriseagentsrcmainresourceslog4jwarnxml"></a> <div class="propset"><h4>Property changes: rhq/trunk/modules/enterprise/agent/src/main/resources/log4j-warn.xml</h4> <pre class="diff"> </pre></div> <a id="svnmimetype"></a> <div class="addfile"><h4>Added: svn:mime-type ( => )</h4> <pre class="diff"> <span class="info">Added: svn:keywords + Date Author Id Revision HeadURL </span></pre></div> <a id="svneolstyle"></a> <div class="addfile"><h4>Added: svn:eol-style ( => )</h4> <pre class="diff"> <span class="info"> Modified: rhq/trunk/modules/enterprise/agent/src/main/resources/log4j.xml </span><span class="cx">=================================================================== </span><span class="rem">--- rhq/trunk/modules/enterprise/agent/src/main/resources/log4j.xml 2008-12-01 05:07:27 UTC (rev 2145) </span><span class="add">+++ rhq/trunk/modules/enterprise/agent/src/main/resources/log4j.xml 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -8,7 +8,7 @@ </span><span class="cx"> <!-- ============================== --> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> </span><span class="rem">- <param name="Threshold" value="INFO"/> </span><span class="add">+ <param name="Threshold" value="DEBUG"/> </span><span class="cx"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> </span><span class="lines">@@ -22,7 +22,7 @@ </span><span class="cx"> <!-- ================================= --> <appender name="FILE" class="org.apache.log4j.RollingFileAppender"> </span><span class="rem">- <param name="Threshold" value="INFO"/> </span><span class="add">+ <param name="Threshold" value="DEBUG"/> </span><span class="cx"> <param name="File" value="logs/agent.log"/> <param name="MaxBackupIndex" value="2"/> <param name="MaxFileSize" value="5000KB"/> </span></pre></div> <a id="rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationsutilCommandTraceUtiljava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/CommandTraceUtil.java (2145 => 2146)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/CommandTraceUtil.java 2008-12-01 05:07:27 UTC (rev 2145) +++ rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/CommandTraceUtil.java 2008-12-01 06:37:57 UTC (rev 2146) </span><span class="lines">@@ -39,10 +39,10 @@ </span><span class="cx"> */ public class CommandTraceUtil { </span><span class="rem">- // name of system property that, when set to anything, dumps the configuration properties of all commands </span><span class="add">+ // name of system property that, when set to true, dumps the configuration properties of all commands </span><span class="cx"> private static final String SYSPROP_TRACE_COMMAND_CONFIG = "rhq.trace-command-config"; </span><span class="rem">- // name of system property that, when set to anything, dumps the results of all command responses </span><span class="add">+ // name of system property that, when set to a number, dumps the results of all command responses </span><span class="cx"> private static final String SYSPROP_TRACE_COMMAND_RESPONSE_RESULTS = "rhq.trace-command-response-results"; // name of system property that, when set to a number, dumps the size of the command when larger than the prop value </span><span class="lines">@@ -54,6 +54,44 @@ </span><span class="cx"> // just a simple cache so we can avoid having to parse the interface names all the time private static Map<String, String> interfaceSimpleNames = null; </span><span class="add">+ public static Boolean getSettingTraceCommandConfig() { + if (System.getProperty(SYSPROP_TRACE_COMMAND_CONFIG) != null) { + return Boolean.getBoolean(SYSPROP_TRACE_COMMAND_CONFIG); + } + return null; // we want to return null if not set + } + + public static void setSettingTraceCommandConfig(Boolean val) { + System.setProperty(SYSPROP_TRACE_COMMAND_CONFIG, (val != null) ? Boolean.toString(val) : "false"); + } + + public static Integer getSettingTraceCommandResponseResults() { + int val = getPropertyInt(SYSPROP_TRACE_COMMAND_RESPONSE_RESULTS); + return (val != -1) ? Integer.valueOf(val) : null; // returns null if not set, numeric otherwise + } + + public static void setSettingTraceCommandResponseResults(Integer val) { + System.setProperty(SYSPROP_TRACE_COMMAND_RESPONSE_RESULTS, (val != null) ? Integer.toString(val) : "-1"); + } + + public static Integer getSettingTraceCommandSizeThreshold() { + int val = getPropertyInt(SYSPROP_TRACE_COMMAND_SIZE_THRESHOLD); + return (val != -1) ? Integer.valueOf(val) : null; // returns null if not set, numeric otherwise + } + + public static void setSettingTraceCommandSizeThreshold(Integer val) { + System.setProperty(SYSPROP_TRACE_COMMAND_SIZE_THRESHOLD, (val != null) ? Integer.toString(val) : "-1"); + } + + public static Integer getSettingTraceCommandResponseSizeThreshold() { + int val = getPropertyInt(SYSPROP_TRACE_COMMAND_RESPONSE_SIZE_THRESHOLD); + return (val != -1) ? Integer.valueOf(val) : null; // returns null if not set, numeric otherwise + } + + public static void setSettingTraceCommandResponseSizeThreshold(Integer val) { + System.setProperty(SYSPROP_TRACE_COMMAND_RESPONSE_SIZE_THRESHOLD, (val != null) ? Integer.toString(val) : "-1"); + } + </span><span class="cx"> /** * Returns the string that represents the command configuration. * </span><span class="lines">@@ -63,7 +101,7 @@ </span><span class="cx"> */ public static String getConfigString(Command command) { Properties config = null; </span><span class="rem">- if (command != null && System.getProperty(SYSPROP_TRACE_COMMAND_CONFIG) != null) { </span><span class="add">+ if (command != null && Boolean.getBoolean(SYSPROP_TRACE_COMMAND_CONFIG)) { </span><span class="cx"> config = command.getConfiguration(); } return (config != null) ? config.toString() : "?"; </span> </pre> </div> </div> </body> </html> |