if (temp == null || !temp.equalsIgnoreCase(LOGGER_FIELD)) {
throw new Exception(
"This key is not a Logger property:" + key);
}
TopicalLogger logger = null;
temp = DottedStringTools.getEnd(key);
String last = DottedStringTools.getLast(temp);
if (last.equalsIgnoreCase(LEVEL_FIELD)) {
// Assigns the level of the logger
logger = (TopicalLogger)
mf.getLogger(DottedStringTools.getBegin(temp));
String levelName = prop.getProperty(key).trim();
Level l = mf.getLevel(levelName);
if (l == null) {
l = parseLevelProp(prop, LEVEL_FIELD + DOT + levelName, mf);
}
if (debug) {
debug("set level to " + l.getName() + " to the logger " + logger.getName());
}
logger.setLevel(l);
} else if (ADDITIVITY_FIELD.equalsIgnoreCase(last)
|| USE_PARENT_FIELD.equalsIgnoreCase(last)) {
logger = (TopicalLogger)
mf.getLogger(DottedStringTools.getBegin(temp));
boolean a = Boolean.getBoolean(prop.getProperty(key).trim());
if (debug) {
debug("set additivity to " + a + " to the logger " + logger.getName());
}
logger.setAdditivity(a);
} else if (CLEAN_HANDLERS_FIELD.equalsIgnoreCase(last)) {
//Already managed iin the read method
} else if (HANDLER_FIELD.equalsIgnoreCase(last)) {
String value = prop.getProperty(key).trim();
StringTokenizer st = new StringTokenizer(value, ", ;:", false);
logger = (TopicalLogger)
mf.getLogger(DottedStringTools.getBegin(temp));
cleanOldHandler(logger);
while(st.hasMoreTokens()) {
String hn = st.nextToken();
Handler h = mf.getHandler(hn);
if (h == null) {
h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
+ DOT + HANDLER_TYPE_ATTRIBUTE, mf);
}
if (debug) {
debug("add handler " + h.getName() + " to the logger " + logger.getName());
}
logger.addHandler(h);
}
} else if (TOPIC_FIELD.equalsIgnoreCase(last)) {
logger = (TopicalLogger)
mf.getLogger(DottedStringTools.getBegin(temp));
String value = prop.getProperty(key).trim();
StringTokenizer st = new StringTokenizer(value, ", ;:", false);
cleanOldHandler(logger);
while(st.hasMoreTokens()) {
String topic = st.nextToken();
if (debug) {
debug("add topic " + topic + " to the logger " + logger.getName());
}
logger.addTopic(topic);
}
} else { //old declaration
temp = DottedStringTools.getBegin(temp); // remove the number
last = DottedStringTools.getLast(temp); // attribute name
temp = DottedStringTools.getBegin(temp); // logger name
logger = (TopicalLogger) mf.getLogger(temp);
if (last.equalsIgnoreCase(HANDLER_FIELD)) {
// Assign an handler to a logger
String value = prop.getProperty(key).trim();
Handler h = mf.getHandler(value);
if (h == null) {
h = parseHandlerProp(prop, HANDLER_FIELD + DOT + value
+ DOT + HANDLER_TYPE_ATTRIBUTE, mf);
}
cleanOldHandler(logger);
if (debug) {
debug("add handler " + h.getName() + " to the logger " + logger.getName());
}
logger.addHandler(h);
} else if (last.equalsIgnoreCase(TOPIC_FIELD)) {
// Assign a topic to a logger
String topic = prop.getProperty(key).trim();
if (debug) {
debug("add topic " + topic + " to the logger " + logger.getName());
}
logger.addTopic(topic);
} else {
throw new Exception(
"Unknown definition" + key + " " + prop.getProperty(key));
}
}