[keycloak-dev] Debug/Trace logging

Stian Thorgersen sthorger at redhat.com
Mon Jan 25 07:16:19 EST 2016


We should not require having two logger fields in a class. Instead we
should create a wrapper logger that gives access to the class logger for
debug, but also the special loggers for other log output. For example:

  final KeycloakLogger logger = KeycloakLogger.getLogger(MyClass.class);

  logger.debug("Hello world!");
  logger.config().serverConfigNotFound();
  logger.realm().realmNameInUse(realmName);

On 22 January 2016 at 18:36, Stan Silvert <ssilvert at redhat.com> wrote:

>  From yesterday's discussion, it was clear that as a group, we consider
> debug/trace logging to be fundamentally different from other logging.
> The loggers I've been concerned with will be logged through a limited
> number of keycloak loggers using broad categories such as User, Realm,
> Config, etc.
>
> But for debug/trace logging, we want the category to be based upon the
> class it was logged from.  That way, you can turn logging on for a
> particular class, package, or sub-package to do your trace.
>
> There is no good way to do both kinds of logging using the same logger
> instance.  Therefore, I propose that debug/trace logging be done the
> same way we've always done it.  Declare a debug/trace logger in your
> class and use that.  Other logging will be done through the keycloak
> logger.
>
> So, to do both kinds of logging in the same class, you declare two loggers:
>
> private static final KeycloakLogger kcLogger = KeycloakLogger.ROOT_LOGGER;
> private static final Logger debugLogger = Logger.getLogger(MyClass.class);
> .....
> kcLogger.CONFIG.localizedMessage("My localized message"); // logged to
> "keycloak-config" category
> .....
> debugLogger.debug("My debug message");  // logged to
> "org.keycloak.mypackage.MyClass" category
>
> Comments?
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160125/89fe5915/attachment.html 


More information about the keycloak-dev mailing list