1
1
/*
2
- * Copyright (c) 2019, 2022 , Oracle Corporation and/or its affiliates.
2
+ * Copyright (c) 2019, 2023 , Oracle and/or its affiliates.
3
3
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
*/
5
5
package oracle .weblogic .deploy .logging ;
6
6
7
7
import java .util .logging .Formatter ;
8
+ import java .util .logging .Level ;
9
+ import java .util .logging .LogManager ;
8
10
import java .util .logging .LogRecord ;
9
11
12
+ import static oracle .weblogic .deploy .logging .WLSDeployLoggingConfig .HANDLER_LEVEL_PROP ;
13
+ import static oracle .weblogic .deploy .logging .WLSDeployLoggingConfig .WLSDEPLOY_STDOUT_CONSOLE_HANDLER ;
14
+
10
15
/**
11
16
* This class removes the Exception record from the LogRecord before formatting so that a
12
17
* stack trace will not print to the Console. The WLSDeployLogFormatter is by default called to
@@ -17,10 +22,22 @@ public class ConsoleFormatter extends Formatter {
17
22
18
23
// Default Formatter if another is not injected
19
24
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
+ }
20
34
21
35
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 );
24
41
}
25
42
26
43
@ SuppressWarnings ("unused" )
0 commit comments