You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2014/06/15 07:09:28 UTC
svn commit: r1602654 - in
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins:
util/PluginBuilder.java util/TypeConverters.java
visitors/PluginAttributeVisitor.java
Author: rpopma
Date: Sun Jun 15 05:09:28 2014
New Revision: 1602654
URL: http://svn.apache.org/r1602654
Log:
improved log format output during configuration
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/TypeConverters.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.java
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.java?rev=1602654&r1=1602653&r2=1602654&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.java Sun Jun 15 05:09:28 2014
@@ -109,10 +109,14 @@ public class PluginBuilder<T> implements
verify();
// first try to use a builder class if one is available
try {
+ LOGGER.debug("Building Plugin[name={}, class={}]. Searching for builder factory method...", pluginType.getElementName(),
+ pluginType.getPluginClass().getName());
final Builder<T> builder = createBuilder(this.clazz);
if (builder != null) {
injectFields(builder);
- return builder.build();
+ T result = builder.build();
+ LOGGER.debug("Built Plugin[name={}] OK from builder factory method.", pluginType.getElementName());
+ return result;
}
} catch (final Exception e) {
LOGGER.catching(Level.DEBUG, e);
@@ -121,10 +125,13 @@ public class PluginBuilder<T> implements
}
// or fall back to factory method if no builder class is available
try {
+ LOGGER.debug("Still building Plugin[name={}, class={}]. Searching for factory method...",
+ pluginType.getElementName(), pluginType.getPluginClass().getName());
final Method factory = findFactoryMethod(this.clazz);
final Object[] params = generateParameters(factory);
@SuppressWarnings("unchecked")
final T plugin = (T) factory.invoke(null, params);
+ LOGGER.debug("Built Plugin[name={}] OK from factory method.", pluginType.getElementName());
return plugin;
} catch (final Exception e) {
LOGGER.catching(Level.DEBUG, e);
@@ -145,11 +152,11 @@ public class PluginBuilder<T> implements
Modifier.isStatic(method.getModifiers())) {
@SuppressWarnings("unchecked")
final Builder<T> builder = (Builder<T>) method.invoke(null);
- LOGGER.debug("Found builder factory method {}.{}.", clazz, method);
+ LOGGER.debug("Found builder factory method [{}]: {}.", method.getName(), method);
return builder;
}
}
- LOGGER.debug("No compatible method annotated with {} found in class {}.", PluginBuilderFactory.class, clazz);
+ LOGGER.debug("No builder factory method found in class {}.", clazz.getName());
return null;
}
@@ -187,21 +194,21 @@ public class PluginBuilder<T> implements
for (final Method method : clazz.getDeclaredMethods()) {
if (method.isAnnotationPresent(PluginFactory.class) &&
Modifier.isStatic(method.getModifiers())) {
- LOGGER.debug("Found factory method {}.{}.", clazz, method);
+ LOGGER.debug("Found factory method [{}]: {}.", method.getName(), method);
return method;
}
}
- LOGGER.debug("No compatible method annotated with {} found in class {}.", PluginFactory.class, clazz);
+ LOGGER.debug("No factory method found in class {}.", clazz.getName());
return null;
}
private Object[] generateParameters(final Method factory) {
+ LOGGER.debug("Generating parameters for factory method [{}]...", factory.getName());
final Class<?>[] types = factory.getParameterTypes();
final Annotation[][] annotations = factory.getParameterAnnotations();
final Object[] args = new Object[annotations.length];
for (int i = 0; i < annotations.length; i++) {
final String[] aliases = extractPluginAliases(annotations[i]);
- LOGGER.debug("Constructing plugin of type {}", clazz);
for (Annotation a : annotations[i]) {
if (a instanceof PluginAliases) {
continue; // already processed
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/TypeConverters.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/TypeConverters.java?rev=1602654&r1=1602653&r2=1602654&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/TypeConverters.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/TypeConverters.java Sun Jun 15 05:09:28 2014
@@ -335,7 +335,8 @@ public final class TypeConverters {
throw new IllegalArgumentException("No type converter found for class: " + clazz.getName());
}
if (s == null) {
- LOGGER.debug("Null string given to convert. Using default [{}].", defaultValue);
+ // don't debug print here, resulting output is hard to understand
+ //LOGGER.debug("Null string given to convert. Using default [{}].", defaultValue);
return parseDefaultValue(converter, defaultValue);
}
try {
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.java?rev=1602654&r1=1602653&r2=1602654&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.java Sun Jun 15 05:09:28 2014
@@ -42,7 +42,11 @@ public class PluginAttributeVisitor exte
final Object defaultValue = findDefaultValue(event);
final Object value = convert(replacedValue, defaultValue);
final Object debugValue = this.annotation.sensitive() ? NameUtil.md5(value + this.getClass().getName()) : value;
- LOGGER.debug("Attribute({}=\"{}\")", name, debugValue);
+ if (value != replacedValue) {
+ LOGGER.debug("Attribute({}=\"{}\") - no value specified, using default.", name, debugValue);
+ } else {
+ LOGGER.debug("Attribute({}=\"{}\")", name, debugValue);
+ }
return value;
}