Augment logging with new resource to allow runtime level changes
In the current code base, the only way to change the logging level of loggers is to update the logger level in properties and restart the service. This introduces downtime and creates issues where sometimes issues are difficult to reproduce in reset environments. To handle this, a new LoggingResource will be added to the core resource to allow different classes to have their logging levels dynamically updated.
To do this, we will make use of the random secure key created for the Cache resource to secure, and a new endpoint that will allow us to change named loggers levels using the built-in JBoss LogManager class, which is welded to slf4j by an adapter. This manager, given the proper parameters, will allow for existing loggers to be updated outside the class, which will be provided as query parameters in the above-mentioned call.
To update a logging level, we can pull the static instance of the LogManager like the code snip below, where clazzName is the fully qualified name of the logger, and level is the name of the level to set. We will want to add more null checking as well, both to the parameters and the presence of loggers to ensure that the requested loggers exist, and the level is valid:
LogManager.getLogManager().getLogger(clazzName).setLevel(Level.parse(level.toUpperCase()));
In future iterations, we will be able to switch this to a UI like the cache resource to allow much easier updates of the logging level for non-Java users, or users less familiar with the code base. We would have the ability to pull the logging levels from the enum, set them in the UI, and cleanly update these without worry. That is a future augment though, and getting the initial code working would be a big value add on its own.