[keycloak-dev] Debug/Trace logging
Stan Silvert
ssilvert at redhat.com
Fri Jan 22 12:36:15 EST 2016
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?
More information about the keycloak-dev
mailing list