I have a basic facility for allowing users to remotely apply changes to the logging files in my application. Some logs are configured using java.util.logging properties files, and some are configured using log4j/log4cplus-style properties files. I d like to do some basic validation of the properties that users try to apply. Namely, I want to assure the following:
- Every logging.properties file must always contain at least a root logger/logging level
- The logger/level must be set to a valid value. That is, they should not be able to set .level = GIBBERISH or anything like that.
- I ll probably allow them to set MaxFileSize and MaxBackupIndex (log4j), and .limit and .count properties (java.util.logging), too.
What s the best way to accomplish this? I can obviously just loop over the keys and values in a Properties object and look for their values in a hard-coded Map or some other data structure that tells what valid properties are, but I m trying to come up with a solution that s a little more elegant than that.