[keycloak-dev] Debug/Trace logging

Stan Silvert ssilvert at redhat.com
Mon Jan 25 09:57:09 EST 2016


On 1/25/2016 9:46 AM, Stian Thorgersen wrote:
> How does it look like from a usage perspective then?
private static final KeycloakLogger logger = 
Logger.getMessageLogger(KeycloakLogger.class, MyClass.class.getName());
.....
logger.CONFIG.localizedMessage("My localized message"); // logged to 
"keycloak-config" category
.....
logger.debug("My debug message");  // logged to 
"org.keycloak.mypackage.MyClass" category
>
> On 25 January 2016 at 15:34, Stan Silvert <ssilvert at redhat.com 
> <mailto:ssilvert at redhat.com>> wrote:
>
>     Actually, the solution was even simpler than that.  I guess I just
>     needed the weekend to clear my head.
>
>
>     On 1/25/2016 7:16 AM, Stian Thorgersen wrote:
>>     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
>>     <mailto: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
>>         <mailto: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/8ebd1f73/attachment.html 


More information about the keycloak-dev mailing list