-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add timestamps to management, server and agent .err logs #12967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
45c3bbe
36060f0
9315f98
15c2f36
bc9fb41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,6 @@ under the License. | |
| <!-- Preserve messages in a local file --> | ||
| <!-- ================================= --> | ||
|
|
||
|
|
||
| <!-- A regular appender --> | ||
| <RollingFile name="FILE" append="true" fileName="@MSLOG@" filePattern="@MSLOG@.%d{yyyy-MM-dd}.gz"> | ||
| <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/> | ||
|
|
@@ -34,7 +33,6 @@ under the License. | |
| <PatternLayout pattern="%d{DEFAULT} %-5p [%c{1.}] (%t:%x) %m%ex%n"/> | ||
| </RollingFile> | ||
|
|
||
|
|
||
| <RollingFile name="INFO-FILE" append="true" fileName="/var/log/cloudstack/management/management-server-info.log" filePattern="/var/log/cloudstack/management/management-server-info.log.%d{yyyy-MM-dd}.gz"> | ||
| <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/> | ||
| <Policies> | ||
|
|
@@ -43,7 +41,6 @@ under the License. | |
| <PatternLayout pattern="%d{DEFAULT} %-5p [%c{1.}] (%t:%x) (logid:%X{logcontextid}) %m%ex%n"/> | ||
| </RollingFile> | ||
|
|
||
|
|
||
| <RollingFile name="APISERVER" append="true" fileName="@APISERVERLOG@" filePattern="@APISERVERLOG@.%d{yyyy-MM-dd}.gz"> | ||
| <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/> | ||
| <Policies> | ||
|
|
@@ -56,7 +53,6 @@ under the License. | |
| <!-- Append warnings+ to the syslog if it is listening on UDP port --> | ||
| <!-- ============================== --> | ||
|
|
||
|
|
||
| <Syslog name="SYSLOG" host="localhost" facility="LOCAL6"> | ||
| <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/> | ||
| <PatternLayout pattern="%-5p [%c{1.}] (%t:%x) %m%ex%n"/> | ||
|
|
@@ -67,8 +63,13 @@ under the License. | |
| <!-- ============================== --> | ||
|
|
||
| <Console name="CONSOLE" target="SYSTEM_OUT"> | ||
| <ThresholdFilter level="OFF" onMatch="ACCEPT" onMismatch="DENY"/> | ||
| <PatternLayout pattern="%-5p [%c{1.}] (%t:%x) %m%ex%n"/> | ||
| <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="ACCEPT"/> | ||
| <PatternLayout pattern="%d{DEFAULT} %-5p [%c{1.}] (%t:%x) %m%ex%n"/> | ||
| </Console> | ||
|
|
||
| <Console name="CONSOLE_ERR" target="SYSTEM_ERR"> | ||
| <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> | ||
| <PatternLayout pattern="%d{DEFAULT} %-5p [%c{1.}] (%t:%x) %m%ex%n"/> | ||
|
Comment on lines
65
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to double check this, @dheeraj12347 . I looked in an env and the .out file already contains the date stamps for each line. The .err file doesn’t .
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You’re right, Daan – .out already had timestamps while .err didn’t. I’ve now added a CONSOLE_ERR appender using SYSTEM_ERR with the same timestamped pattern, so stderr (and thus the .err files) will get timestamps as well.
Comment on lines
+69
to
+72
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve now updated usage/conf/log4j-cloud_usage.xml.in to add a CONSOLE_ERR appender targeting SYSTEM_ERR with a timestamped pattern, so usage.err will also get timestamps in line with issue #12887.
Comment on lines
65
to
+72
|
||
| </Console> | ||
|
Comment on lines
65
to
73
|
||
| </Appenders> | ||
|
|
||
|
|
@@ -101,6 +102,7 @@ under the License. | |
| <Logger name="org.apache.cloudstack.alerts" additivity="false" level="WARN"> | ||
| <AppenderRef ref="SYSLOG"/> | ||
| <AppenderRef ref="CONSOLE"/> | ||
| <AppenderRef ref="CONSOLE_ERR"/> | ||
| <AppenderRef ref="FILE"/> | ||
| <AppenderRef ref="SNMP"/> | ||
| <AppenderRef ref="ALERTSYSLOG"/> | ||
|
|
@@ -113,6 +115,7 @@ under the License. | |
| <Root level="INFO"> | ||
| <AppenderRef ref="SYSLOG"/> | ||
| <AppenderRef ref="CONSOLE"/> | ||
| <AppenderRef ref="CONSOLE_ERR"/> | ||
| <AppenderRef ref="FILE"/> | ||
| <AppenderRef ref="INFO-FILE"/> | ||
| </Root> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,11 @@ public class ConsoleProxy { | |
| static String factoryClzName; | ||
| static boolean standaloneStart = false; | ||
|
|
||
| /** | ||
| * Session timeout in milliseconds, default 300000 (5 minutes). | ||
| */ | ||
| public static int sessionTimeoutMillis = 300000; | ||
|
|
||
| static String encryptorPassword = "Dummy"; | ||
| static final String[] skipProperties = new String[]{"certificate", "cacertificate", "keystore_password", "privatekey"}; | ||
|
|
||
|
|
@@ -92,11 +97,13 @@ public static void addAllowedSession(String sessionUuid) { | |
| private static void configLog4j() { | ||
| final ClassLoader loader = Thread.currentThread().getContextClassLoader(); | ||
| URL configUrl = loader.getResource("/conf/log4j-cloud.xml"); | ||
| if (configUrl == null) | ||
| if (configUrl == null) { | ||
| configUrl = ClassLoader.getSystemResource("log4j-cloud.xml"); | ||
| } | ||
|
|
||
| if (configUrl == null) | ||
| if (configUrl == null) { | ||
| configUrl = ClassLoader.getSystemResource("conf/log4j-cloud.xml"); | ||
| } | ||
|
|
||
| if (configUrl != null) { | ||
| try { | ||
|
|
@@ -121,9 +128,8 @@ private static void configLog4j() { | |
| private static void configProxy(Properties conf) { | ||
| LOGGER.info("Configure console proxy..."); | ||
| for (Object key : conf.keySet()) { | ||
| LOGGER.info("Property " + (String)key + ": " + conf.getProperty((String)key)); | ||
| if (!ArrayUtils.contains(skipProperties, key)) { | ||
| LOGGER.info("Property " + (String)key + ": " + conf.getProperty((String)key)); | ||
| LOGGER.info("Property " + (String) key + ": " + conf.getProperty((String) key)); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -165,13 +171,31 @@ private static void configProxy(Properties conf) { | |
| defaultBufferSize = Integer.parseInt(s); | ||
| LOGGER.info("Setting defaultBufferSize=" + defaultBufferSize); | ||
| } | ||
|
|
||
| // Read consoleproxy.session.timeout in milliseconds. | ||
| s = conf.getProperty("consoleproxy.session.timeout"); | ||
| if (s != null) { | ||
| try { | ||
| int parsedTimeout = Integer.parseInt(s); | ||
| if (parsedTimeout < 1000) { | ||
| LOGGER.warn("Invalid value for consoleproxy.session.timeout: " + s | ||
| + " ms, must be >= 1000 ms, keeping default " + sessionTimeoutMillis + " ms"); | ||
| } else { | ||
| sessionTimeoutMillis = parsedTimeout; | ||
| LOGGER.info("Setting consoleproxy.session.timeout=" + sessionTimeoutMillis + " ms"); | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| LOGGER.warn("Invalid value for consoleproxy.session.timeout: " + s | ||
| + ", keeping default " + sessionTimeoutMillis + " ms", e); | ||
| } | ||
| } | ||
|
Comment on lines
83
to
+191
|
||
| } | ||
|
|
||
| public static ConsoleProxyServerFactory getHttpServerFactory() { | ||
| try { | ||
| Class<?> clz = Class.forName(factoryClzName); | ||
| try { | ||
| ConsoleProxyServerFactory factory = (ConsoleProxyServerFactory)clz.newInstance(); | ||
| ConsoleProxyServerFactory factory = (ConsoleProxyServerFactory) clz.newInstance(); | ||
| factory.init(ConsoleProxy.ksBits, ConsoleProxy.ksPassword); | ||
| return factory; | ||
| } catch (InstantiationException e) { | ||
|
|
@@ -243,7 +267,7 @@ public static ConsoleProxyAuthenticationResult authenticateConsoleAccess(Console | |
| } | ||
|
|
||
| if (result != null && result instanceof String) { | ||
| authResult = new Gson().fromJson((String)result, ConsoleProxyAuthenticationResult.class); | ||
| authResult = new Gson().fromJson((String) result, ConsoleProxyAuthenticationResult.class); | ||
| } else { | ||
| LOGGER.error("Invalid authentication return object " + result + " for vm: " + param.getClientTag() + ", decline the access"); | ||
| authResult.setSuccess(false); | ||
|
|
@@ -318,19 +342,25 @@ public static void startWithContext(Properties conf, Object context, byte[] ksBi | |
| LOGGER.error("Unable to setup private channel due to ClassNotFoundException", e); | ||
| } | ||
|
|
||
| // ensure we have a Properties object before merging defaults | ||
| if (conf == null) { | ||
| conf = new Properties(); | ||
| } | ||
|
|
||
| // merge properties from conf file | ||
| InputStream confs = ConsoleProxy.class.getResourceAsStream("/conf/consoleproxy.properties"); | ||
| Properties props = new Properties(); | ||
| if (confs == null) { | ||
| final File file = PropertiesUtil.findConfigFile("consoleproxy.properties"); | ||
| if (file == null) | ||
| if (file == null) { | ||
| LOGGER.info("Can't load consoleproxy.properties from classpath, will use default configuration"); | ||
| else | ||
| } else { | ||
| try { | ||
| confs = new FileInputStream(file); | ||
| } catch (FileNotFoundException e) { | ||
| LOGGER.info("Ignoring file not found exception and using defaults"); | ||
| } | ||
| } | ||
| } | ||
| if (confs != null) { | ||
| try { | ||
|
|
@@ -339,15 +369,18 @@ public static void startWithContext(Properties conf, Object context, byte[] ksBi | |
| for (Object key : props.keySet()) { | ||
| // give properties passed via context high priority, treat properties from consoleproxy.properties | ||
| // as default values | ||
| if (conf.get(key) == null) | ||
| if (conf.get(key) == null) { | ||
| conf.put(key, props.get(key)); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| LOGGER.error(e.toString(), e); | ||
| } | ||
| } | ||
| try { | ||
| confs.close(); | ||
| if (confs != null) { | ||
| confs.close(); | ||
| } | ||
| } catch (IOException e) { | ||
| LOGGER.error("Failed to close consolepropxy.properties : " + e.toString(), e); | ||
| } | ||
|
|
@@ -481,8 +514,9 @@ public static ConsoleProxyClient getVncViewer(ConsoleProxyClientParam param) thr | |
| ConsoleProxyClientStatsCollector statsCollector = getStatsCollector(); | ||
| String loadInfo = statsCollector.getStatsReport(); | ||
| reportLoadInfo(loadInfo); | ||
| if (LOGGER.isDebugEnabled()) | ||
| if (LOGGER.isDebugEnabled()) { | ||
| LOGGER.debug("Report load change : " + loadInfo); | ||
| } | ||
| } | ||
|
|
||
| return viewer; | ||
|
|
@@ -506,13 +540,15 @@ public static ConsoleProxyClient getAjaxVncViewer(ConsoleProxyClientParam param, | |
| // protected against malicious attack by modifying URL content | ||
| if (ajaxSession != null) { | ||
| long ajaxSessionIdFromUrl = Long.parseLong(ajaxSession); | ||
| if (ajaxSessionIdFromUrl != viewer.getAjaxSessionId()) | ||
| if (ajaxSessionIdFromUrl != viewer.getAjaxSessionId()) { | ||
| throw new AuthenticationException("Cannot use the existing viewer " + viewer + ": modified AJAX session id"); | ||
| } | ||
| } | ||
|
|
||
| if (param.getClientHostPassword() == null || param.getClientHostPassword().isEmpty() || | ||
| !param.getClientHostPassword().equals(viewer.getClientHostPassword())) | ||
| !param.getClientHostPassword().equals(viewer.getClientHostPassword())) { | ||
| throw new AuthenticationException("Cannot use the existing viewer " + viewer + ": bad sid"); | ||
| } | ||
|
|
||
| if (!viewer.isFrontEndAlive()) { | ||
|
|
||
|
|
@@ -526,8 +562,9 @@ public static ConsoleProxyClient getAjaxVncViewer(ConsoleProxyClientParam param, | |
| ConsoleProxyClientStatsCollector statsCollector = getStatsCollector(); | ||
| String loadInfo = statsCollector.getStatsReport(); | ||
| reportLoadInfo(loadInfo); | ||
| if (LOGGER.isDebugEnabled()) | ||
| if (LOGGER.isDebugEnabled()) { | ||
| LOGGER.debug("Report load change : " + loadInfo); | ||
| } | ||
| } | ||
| return viewer; | ||
| } | ||
|
|
@@ -593,7 +630,7 @@ public void execute(Runnable r) { | |
| } | ||
|
|
||
| public static ConsoleProxyNoVncClient getNoVncViewer(ConsoleProxyClientParam param, String ajaxSession, | ||
| Session session) throws AuthenticationException { | ||
| Session session) throws AuthenticationException { | ||
| boolean reportLoadChange = false; | ||
| String clientKey = param.getClientMapKey(); | ||
| LOGGER.debug("Getting NoVNC viewer for {}. Session requires new viewer: {}, client tag: {}. session UUID: {}", | ||
|
|
@@ -609,8 +646,9 @@ public static ConsoleProxyNoVncClient getNoVncViewer(ConsoleProxyClientParam par | |
| reportLoadChange = true; | ||
| } else { | ||
| if (param.getClientHostPassword() == null || param.getClientHostPassword().isEmpty() || | ||
| !param.getClientHostPassword().equals(viewer.getClientHostPassword())) | ||
| !param.getClientHostPassword().equals(viewer.getClientHostPassword())) { | ||
| throw new AuthenticationException("Cannot use the existing viewer " + viewer + ": bad sid"); | ||
| } | ||
|
|
||
| try { | ||
| authenticationExternally(param); | ||
|
|
@@ -620,7 +658,7 @@ public static ConsoleProxyNoVncClient getNoVncViewer(ConsoleProxyClientParam par | |
| } | ||
| LOGGER.info("Initializing new novnc client and disconnecting existing session"); | ||
| try { | ||
| ((ConsoleProxyNoVncClient)viewer).getSession().disconnect(); | ||
| ((ConsoleProxyNoVncClient) viewer).getSession().disconnect(); | ||
| } catch (IOException e) { | ||
| LOGGER.error("Exception while disconnect session of novnc viewer object: " + viewer, e); | ||
| } | ||
|
|
@@ -635,10 +673,11 @@ public static ConsoleProxyNoVncClient getNoVncViewer(ConsoleProxyClientParam par | |
| ConsoleProxyClientStatsCollector statsCollector = getStatsCollector(); | ||
| String loadInfo = statsCollector.getStatsReport(); | ||
| reportLoadInfo(loadInfo); | ||
| if (LOGGER.isDebugEnabled()) | ||
| if (LOGGER.isDebugEnabled()) { | ||
| LOGGER.debug("Report load change : " + loadInfo); | ||
| } | ||
| } | ||
| return (ConsoleProxyNoVncClient)viewer; | ||
| return (ConsoleProxyNoVncClient) viewer; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.