diff --git a/services/src/main/java/org/keycloak/services/ServicesLogger.java b/services/src/main/java/org/keycloak/services/ServicesLogger.java index 3fb387459a..2ddfa1d6fe 100644 --- a/services/src/main/java/org/keycloak/services/ServicesLogger.java +++ b/services/src/main/java/org/keycloak/services/ServicesLogger.java @@ -287,4 +287,12 @@ public interface ServicesLogger extends BasicLogger { @LogMessage(level = ERROR) @Message(id=62, value="Error occurred during sync of changed users") void errorDuringChangedUserSync(@Cause Throwable t); + + @LogMessage(level = WARN) + @Message(id=63, value="Failed to format message due to: %s") + void failedToFormatMessage(String cause); + + @LogMessage(level = WARN) + @Message(id=64, value="Failed to load messages") + void failedToloadMessages(@Cause IOException ioe); } diff --git a/services/src/main/java/org/keycloak/services/messages/AdminMessagesProvider.java b/services/src/main/java/org/keycloak/services/messages/AdminMessagesProvider.java index 7b6b3ed967..9140b31dd5 100644 --- a/services/src/main/java/org/keycloak/services/messages/AdminMessagesProvider.java +++ b/services/src/main/java/org/keycloak/services/messages/AdminMessagesProvider.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @author tags. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package org.keycloak.services.messages; import java.io.IOException; @@ -5,16 +21,16 @@ import java.net.URL; import java.text.MessageFormat; import java.util.Locale; import java.util.Properties; -import org.jboss.logging.Logger; import org.keycloak.models.KeycloakSession; import org.keycloak.messages.MessagesProvider; +import org.keycloak.services.ServicesLogger; /** * @author Leonardo Zanivan */ public class AdminMessagesProvider implements MessagesProvider { - private static final Logger logger = Logger.getLogger(AdminMessagesProvider.class); + private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private KeycloakSession session; private Locale locale; @@ -33,7 +49,7 @@ public class AdminMessagesProvider implements MessagesProvider { try { return new MessageFormat(message, locale).format(parameters); } catch (Exception e) { - logger.warnf("Failed to format message due to: %s", e.getMessage()); + logger.failedToFormatMessage(e.getMessage()); return message; } } @@ -55,7 +71,7 @@ public class AdminMessagesProvider implements MessagesProvider { try { properties.load(url.openStream()); } catch (IOException ex) { - logger.warn("Failed to load messages", ex); + logger.failedToloadMessages(ex); } }