Package org.apache.log4j.config
Class Log4j1ConfigurationParser
java.lang.Object
org.apache.log4j.config.Log4j1ConfigurationParser
Experimental parser for Log4j 1.2 properties configuration files.
This class is not thread-safe.
From the Log4j 1.2 Javadocs:
All option values admit variable substitution. The syntax of variable substitution is similar to that of Unix shells. The string between an opening "${" and closing "}" is interpreted as a key. The value of the substituted variable can be defined as a system property or in the configuration file itself. The value of the key is first searched in the system properties, and if not found there, it is then searched in the configuration file being parsed. The corresponding value replaces the ${variableName} sequence. For example, if java.home system property is set to /home/xyz, then every occurrence of the sequence ${java.home} will be interpreted as /home/xyz.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfigurationBuilder
<BuiltConfiguration> private static final String
private static final String
private static final String
private final Properties
private static final String
private static final String
private static final String
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
buildAppender
(String appenderName, String appenderClass) private void
buildAppenderLayout
(String name, AppenderComponentBuilder appenderBuilder) private void
buildAttribute
(String componentName, ComponentBuilder<?> componentBuilder, String sourceAttributeName, String targetAttributeName) Parses a Log4j 1.2 properties configuration file in ISO 8859-1 encoding into a ConfigurationBuilder.private void
buildConsoleAppender
(String appenderName) private void
buildDailyRollingFileAppender
(String appenderName) private void
buildFileAppender
(String appenderName) private void
buildFileAppender
(String appenderName, AppenderComponentBuilder appenderBuilder) private void
buildLoggers
(String prefix) private void
buildMandatoryAttribute
(String componentName, ComponentBuilder<?> componentBuilder, String sourceAttributeName, String targetAttributeName) private void
buildNullAppender
(String appenderName) private void
private void
buildRollingFileAppender
(String appenderName) private void
buildRootLogger
(String rootLoggerValue) private String
getLevelString
(String[] loggerParts, String defaultLevel) private String
getLog4jAppenderValue
(String appenderName, String attributeName) private String
getLog4jAppenderValue
(String appenderName, String attributeName, String defaultValue) private String
getLog4jValue
(String key) private String
getProperty
(String key) private String
getProperty
(String key, String defaultValue) private LayoutComponentBuilder
newPatternLayout
(String pattern) private void
reportWarning
(String msg) private void
-
Field Details
-
COMMA_DELIMITED_RE
- See Also:
-
ROOTLOGGER
- See Also:
-
ROOTCATEGORY
- See Also:
-
TRUE
- See Also:
-
FALSE
- See Also:
-
RELATIVE
- See Also:
-
NULL
- See Also:
-
properties
-
builder
-
-
Constructor Details
-
Log4j1ConfigurationParser
public Log4j1ConfigurationParser()
-
-
Method Details
-
buildConfigurationBuilder
public ConfigurationBuilder<BuiltConfiguration> buildConfigurationBuilder(InputStream input) throws IOException Parses a Log4j 1.2 properties configuration file in ISO 8859-1 encoding into a ConfigurationBuilder.- Parameters:
input
- InputStream to read from is assumed to be ISO 8859-1, and will not be closed.- Returns:
- the populated ConfigurationBuilder, never null
- Throws:
IOException
- if unable to read the inputConfigurationException
- if the input does not contain a valid configuration
-
buildProperties
private void buildProperties() -
warn
-
buildClassToPropertyPrefixMap
-
buildAppender
-
buildConsoleAppender
-
buildFileAppender
-
buildFileAppender
-
buildDailyRollingFileAppender
-
buildRollingFileAppender
-
buildAttribute
private void buildAttribute(String componentName, ComponentBuilder<?> componentBuilder, String sourceAttributeName, String targetAttributeName) -
buildMandatoryAttribute
private void buildMandatoryAttribute(String componentName, ComponentBuilder<?> componentBuilder, String sourceAttributeName, String targetAttributeName) -
buildNullAppender
-
buildAppenderLayout
-
newPatternLayout
-
buildRootLogger
-
getLevelString
-
buildLoggers
-
getLog4jAppenderValue
-
getProperty
-
getProperty
-
getLog4jAppenderValue
-
getLog4jValue
-
reportWarning
-