Skip to content

Commit 45b89e1

Browse files
committed
Merge branch 'wdt-808-main' into 'main'
Enhancing wlsdeploy.debugToStdout system property to log exceptions to stdout/stderr See merge request weblogic-cloud/weblogic-deploy-tooling!1573
2 parents 97c0e66 + 692ec73 commit 45b89e1

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

core/src/main/java/oracle/weblogic/deploy/logging/ConsoleFormatter.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle Corporation and/or its affiliates.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.logging;
66

77
import java.util.logging.Formatter;
8+
import java.util.logging.Level;
9+
import java.util.logging.LogManager;
810
import java.util.logging.LogRecord;
911

12+
import static oracle.weblogic.deploy.logging.WLSDeployLoggingConfig.HANDLER_LEVEL_PROP;
13+
import static oracle.weblogic.deploy.logging.WLSDeployLoggingConfig.WLSDEPLOY_STDOUT_CONSOLE_HANDLER;
14+
1015
/**
1116
* This class removes the Exception record from the LogRecord before formatting so that a
1217
* stack trace will not print to the Console. The WLSDeployLogFormatter is by default called to
@@ -17,10 +22,22 @@ public class ConsoleFormatter extends Formatter {
1722

1823
// Default Formatter if another is not injected
1924
private Formatter formatter = new WLSDeployLogFormatter();
25+
private boolean suppressExceptions = true;
26+
27+
public ConsoleFormatter() {
28+
String stdoutHandlerLevel =
29+
LogManager.getLogManager().getProperty(WLSDEPLOY_STDOUT_CONSOLE_HANDLER + HANDLER_LEVEL_PROP);
30+
if (stdoutHandlerLevel != null && stdoutHandlerLevel.equalsIgnoreCase(Level.ALL.toString())) {
31+
suppressExceptions = false;
32+
}
33+
}
2034

2135
public String format(LogRecord logRecord) {
22-
LogRecord cloned = LoggingUtils.cloneRecordWithoutException(logRecord);
23-
return formatter.format(cloned);
36+
LogRecord recordToPublish = logRecord;
37+
if (suppressExceptions) {
38+
recordToPublish = LoggingUtils.cloneRecordWithoutException(logRecord);
39+
}
40+
return formatter.format(recordToPublish);
2441
}
2542

2643
@SuppressWarnings("unused")

core/src/main/java/oracle/weblogic/deploy/logging/WLSDeployLoggingConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.logging;
@@ -37,7 +37,7 @@ public class WLSDeployLoggingConfig {
3737
private static final String HANDLERS_PROP = "handlers";
3838
private static final String CONFIG_PROP = "config";
3939

40-
private static final String WLSDEPLOY_STDOUT_CONSOLE_HANDLER =
40+
/* package */ static final String WLSDEPLOY_STDOUT_CONSOLE_HANDLER =
4141
"oracle.weblogic.deploy.logging.StdoutHandler";
4242
private static final String WLSDEPLOY_STDERR_CONSOLE_HANDLER =
4343
"oracle.weblogic.deploy.logging.StderrHandler";
@@ -52,7 +52,7 @@ public class WLSDeployLoggingConfig {
5252
FILE_HANDLER
5353
));
5454

55-
private static final String HANDLER_LEVEL_PROP = ".level";
55+
/* package */ static final String HANDLER_LEVEL_PROP = ".level";
5656
private static final String HANDLER_FILTER_PROP = ".filter";
5757
private static final String HANDLER_FORMATTER_PROP = ".formatter";
5858
private static final String HANDLER_PATTERN_PROP = ".pattern";

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<dependency>
105105
<groupId>com.google.guava</groupId>
106106
<artifactId>guava</artifactId>
107-
<version>32.1.3-jre</version>
107+
<version>33.0.0-jre</version>
108108
</dependency>
109109
<dependency>
110110
<groupId>javax.xml.bind</groupId>
@@ -135,7 +135,7 @@
135135
<plugin>
136136
<groupId>org.apache.maven.plugins</groupId>
137137
<artifactId>maven-compiler-plugin</artifactId>
138-
<version>3.11.0</version>
138+
<version>3.12.0</version>
139139
</plugin>
140140
<plugin>
141141
<groupId>org.apache.maven.plugins</groupId>

0 commit comments

Comments
 (0)