codeconsole commented on code in PR #15564:
URL: https://github.com/apache/grails-core/pull/15564#discussion_r3172358947


##########
grails-web-mvc/src/main/groovy/org/grails/web/errors/GrailsExceptionResolver.java:
##########
@@ -261,6 +266,70 @@ protected void logStackTrace(Exception e, 
HttpServletRequest request) {
         LOG.error(getRequestLogMessage(e, request), e);
     }
 
+    /**
+     * When the {@code grails.exceptionresolver.logFullStackTrace} property is 
enabled,
+     * emits the unfiltered stack trace to the dedicated {@code StackTrace} 
logger.
+     * Must be invoked <em>before</em> {@link #filterStackTrace(Exception)} — 
once the
+     * filterer calls {@code setStackTrace(clean)}, the original frames are 
gone and
+     * this method can only log the already-trimmed trace.
+     */
+    protected void logFullStackTraceIfEnabled(Exception e) {
+        if (shouldLogFullStackTrace()) {
+            
DefaultStackTraceFilterer.STACK_LOG.error(StackTraceFilterer.FULL_STACK_TRACE_MESSAGE,
 e);
+        }
+    }
+
+    protected boolean shouldLogFullStackTrace() {
+        Config config = grailsApplication != null ? 
grailsApplication.getConfig() : null;
+        return config != null && 
config.getProperty(Settings.SETTING_LOG_FULL_STACKTRACE, Boolean.class, false);
+    }
+
+    protected boolean shouldLogAuditor() {
+        Config config = grailsApplication != null ? 
grailsApplication.getConfig() : null;
+        return config != null && 
config.getProperty(Settings.SETTING_LOG_AUDITOR, Boolean.class, true);
+    }
+
+    protected boolean shouldLogRemoteAddr() {
+        Config config = grailsApplication != null ? 
grailsApplication.getConfig() : null;
+        return config != null && 
config.getProperty(Settings.SETTING_LOG_REMOTE_ADDR, Boolean.class, true);
+    }
+
+    /**
+     * Resolves the client address to include in the exception log headline. 
The default
+     * returns {@link HttpServletRequest#getRemoteAddr()} — the container's 
view of the
+     * TCP peer, which reflects forwarded-header handling only when the 
servlet container
+     * is configured to trust a proxy chain (for example Spring Boot's
+     * {@code server.forward-headers-strategy}). Subclasses can override this 
to apply a
+     * different resolution strategy; the returned value (null or empty to 
omit) is
+     * appended verbatim as {@code ip: <value>}.
+     */
+    protected String resolveRemoteAddr(HttpServletRequest request) {
+        return request.getRemoteAddr();

Review Comment:
   no defaults to false



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to