diff --git a/services/src/main/java/org/keycloak/services/ServicesLogger.java b/services/src/main/java/org/keycloak/services/ServicesLogger.java index e0ff699fe1..ffd1132e8d 100644 --- a/services/src/main/java/org/keycloak/services/ServicesLogger.java +++ b/services/src/main/java/org/keycloak/services/ServicesLogger.java @@ -393,4 +393,12 @@ public interface ServicesLogger extends BasicLogger { @LogMessage(level = ERROR) @Message(id=88, value="Failed to send execute actions email") void failedToSendActionsEmail(@Cause EmailException e); + + @LogMessage(level = ERROR) + @Message(id=89, value="Failed to run scheduled task %s") + void failedToRunScheduledTask(@Cause Throwable t, String taskClass); + + @LogMessage(level = ERROR) + @Message(id=90, value="Failed to close ProviderSession") + void failedToCloseProviderSession(@Cause Throwable t); } diff --git a/services/src/main/java/org/keycloak/services/scheduled/ScheduledTaskRunner.java b/services/src/main/java/org/keycloak/services/scheduled/ScheduledTaskRunner.java index c892e7086c..44381d22dc 100644 --- a/services/src/main/java/org/keycloak/services/scheduled/ScheduledTaskRunner.java +++ b/services/src/main/java/org/keycloak/services/scheduled/ScheduledTaskRunner.java @@ -1,15 +1,15 @@ package org.keycloak.services.scheduled; -import org.jboss.logging.Logger; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; +import org.keycloak.services.ServicesLogger; /** * @author Stian Thorgersen */ public class ScheduledTaskRunner implements Runnable { - private static final Logger logger = Logger.getLogger(ScheduledTaskRunner.class); + private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private final KeycloakSessionFactory sessionFactory; private final ScheduledTask task; @@ -29,14 +29,14 @@ public class ScheduledTaskRunner implements Runnable { logger.debug("Executed scheduled task " + task.getClass().getSimpleName()); } catch (Throwable t) { - logger.error("Failed to run scheduled task " + task.getClass().getSimpleName(), t); + logger.failedToRunScheduledTask(t, task.getClass().getSimpleName()); session.getTransaction().rollback(); } finally { try { session.close(); } catch (Throwable t) { - logger.error("Failed to close ProviderSession", t); + logger.failedToCloseProviderSession(t); } } }