final Level level = Level.toLevel(levelParam);
if(level == null){
throw new IllegalArgumentException("'" + levelParam + "' is not a valid log4j level");
}
if (BindableModel.class.isAssignableFrom(field.getType())) {
BindableModel model = context.getFieldObject(field, BindableModel.class);
Binding binding = new Binding() {
public <T extends Enum<?> & ModelUpdate> void update(T... changed) {
for (T t : changed){
Logger logger = LogManager.getLogger(loggerParam);
Level configuredLevel = logger.getLevel();
if(configuredLevel == null || configuredLevel.isGreaterOrEqual(level)){
logger.log(level, t.toString() + ": " + fieldName, null);
}
}
}
};
model.bind(binding);
bindings.add(binding);
} else {
throw new BindingException("Can only log a BindableModel.");
}
}