Package org.apache.logging.log4j.plugins
Annotation Interface PluginAttribute
@Documented
@Retention(RUNTIME)
@Target({PARAMETER,FIELD,METHOD,TYPE_USE})
@NameProvider(PluginAttributeNameProvider.class)
@QualifierType
public @interface PluginAttribute
Qualifier for a plugin attribute for configuration options of a plugin. A plugin attribute has a case-insensitive
name and a string value which may be converted to a different type when a
TypeConverter plugin exists for
a target type. In a plugin class, attributes can be injected via several means:
- a static method annotated with
Factoryor some otherFactoryTypeannotation can have parameters annotated with@PluginAttribute - a constructor annotated with
Injectcan have parameters annotated with@PluginAttribute - a field can be annotated with
PluginAttribute— note that any default value specified for this field may be overwritten with the default value specified in this annotation when the configuration attribute has no specified value - a method parameter can be annotated with
PluginAttribute - an instance returned from a static
Factorymethod may have its fields and methods injected if the instance implementsSupplier
Default values may be specified via one of the defaultType attributes depending on the
annotated type. Unlisted types that are supported by a corresponding
TypeConverter may use the defaultString() attribute.
Plugin attributes with sensitive data such as passwords should set sensitive() to true to avoid
having their values output in debug logs.
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanSpecifies the default boolean value to use.byteSpecifies the default byte value to use.charSpecifies the default byte value to use.Class<?>Specifies the defaultClassvalue to use.doubleSpecifies the default double floating point value to use.floatSpecifies the default floating point value to use.intSpecifies the default integer value to use.longSpecifies the default long value to use.shortSpecifies the default long value to use.Specifies the default value this attribute should use if none is provided or if the provided value is invalid.booleanIndicates that this attribute is a sensitive one that shouldn't be logged directly.Specifies the name of the attribute (case-insensitive) this annotation corresponds to.
-
Element Details
-
defaultBoolean
boolean defaultBooleanSpecifies the default boolean value to use.- Returns:
- the default boolean value.
- Default:
- false
-
defaultByte
byte defaultByteSpecifies the default byte value to use.- Returns:
- the default byte value;
- Default:
- (byte)0x00
-
defaultChar
char defaultCharSpecifies the default byte value to use.- Returns:
- the default char value.
- Default:
- '\u0000'
-
defaultClass
Class<?> defaultClassSpecifies the defaultClassvalue to use.- Returns:
- the default class value.
- Default:
- java.lang.Object.class
-
defaultDouble
double defaultDoubleSpecifies the default double floating point value to use.- Returns:
- the default double value;
- Default:
- 0.0
-
defaultFloat
float defaultFloatSpecifies the default floating point value to use.- Returns:
- the default float value.
- Default:
- 0.0f
-
defaultInt
int defaultIntSpecifies the default integer value to use.- Returns:
- the default integer value.
- Default:
- 0
-
defaultLong
long defaultLongSpecifies the default long value to use.- Returns:
- the default long value;
- Default:
- 0L
-
defaultShort
short defaultShortSpecifies the default long value to use.- Returns:
- the default short value.
- Default:
- 0
-
defaultString
String defaultStringSpecifies the default value this attribute should use if none is provided or if the provided value is invalid.- Returns:
- the default String value.
- Default:
- ""
-
value
String valueSpecifies the name of the attribute (case-insensitive) this annotation corresponds to. If blank, defaults to using reflection on the annotated element as such:- Field: uses the field name.
- Method: when named
setXYZorwithXYZ, uses the rest (XYZ) of the method name. Otherwise, uses the name of the first parameter. - Parameter: uses the parameter name.
- Returns:
- the value;
- Default:
- ""
-
sensitive
boolean sensitiveIndicates that this attribute is a sensitive one that shouldn't be logged directly. Such attributes will instead be output as a hashed value.- Returns:
- true if the attribute should be considered sensitive.
- Default:
- false
-