{"record":{"id":"b35f012108d38f45","repo":"apereo/cas","slug":"warn-logger-getmessage-throwable-throwable-b35f01","errorCode":null,"errorMessage":"warn(logger, getMessage(throwable), throwable)","messagePattern":"warn\\(logger, getMessage\\(throwable\\), throwable\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/LoggingUtils.java","lineNumber":140,"sourceCode":"    /**\n     * Log Error.\n     *\n     * @param logger    the logger\n     * @param throwable the throwable\n     */\n    public static void error(final Logger logger, final Throwable throwable) {\n        if (throwable != null) {\n            error(logger, getMessage(throwable), throwable);\n        }\n    }\n\n    /**\n     * Log warning.\n     *\n     * @param logger    the logger\n     * @param throwable the throwable\n     */\n    public static void warn(final Logger logger, final Throwable throwable) {\n        warn(logger, getMessage(throwable), throwable);\n    }\n\n    /**\n     * Log warning.\n     *\n     * @param logger    the logger\n     * @param message   the message\n     * @param throwable the throwable\n     */\n    public static void warn(final Logger logger, final String message, final Throwable throwable) {\n        FunctionUtils.doIf(LOG_MESSAGE_SUMMARIZER.shouldSummarize(logger),\n                _ -> logger.warn(LOG_MESSAGE_SUMMARIZER.summarizeStackTrace(message, throwable)),\n                _ -> logger.warn(message, throwable))\n            .accept(throwable);\n    }\n\n    /**","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/LoggingUtils.java#L122-L158","documentation":"LoggingUtils.warn(Logger, Throwable) is a convenience that logs an exception at WARN level: it derives the message via getMessage(throwable) (falling back to the class name when all messages are null) and delegates to warn(logger, message, throwable). It exists to normalize exception logging across CAS, including stack-trace summarization.","triggerScenarios":"Any CAS code catching a non-fatal exception and calling LoggingUtils.warn(LOGGER, e) instead of logger.warn directly. It throws nothing itself; the 'error' entry is the emitted warn event.","commonSituations":"Recoverable I/O or resource-check failures (e.g. resource existence probes); best-effort background tasks whose failure should not fail the request; developers unsure how to log a throwable consistently.","solutions":["Inspect the derived message (exception message or exception class name) to identify the root cause","If the stack trace is summarized/truncated and you need details, enable full stack traces or raise the log level as configured for LOG_MESSAGE_SUMMARIZER","Fix the underlying recoverable condition instead of suppressing the warn"],"exampleFix":"// before\n} catch (Exception e) {\n    LOGGER.warn(\"something failed\", e); // inconsistent, full trace spam\n}\n// after\n} catch (Exception e) {\n    LoggingUtils.warn(LOGGER, e); // normalized message + summarizer-aware\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    riskyOperation();\n} catch (Exception e) {\n    LoggingUtils.warn(LOGGER, e);\n    // continue with fallback behavior\n}","preventionTips":["Use LoggingUtils uniformly so messages and trace summarization stay consistent","Only swallow exceptions as WARN when the operation is genuinely optional/best-effort","Know how to flip stack-trace summarization on when debugging"],"tags":["logging","exception-handling","warn"],"backgroundTag":"stack-trace-summarized","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}