Class ConfigurationSource
java.lang.Object
org.apache.logging.log4j.core.config.ConfigurationSource
Represents the source for the logging configuration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConfigurationSourceConfigurationSource to use withCompositeConfiguration.static final ConfigurationSourceConfigurationSource to use with Configurations that do not require a "real" configuration source. -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationSource(InputStream stream) Constructs a newConfigurationSourcewith the specified input stream.ConfigurationSource(InputStream stream, File file) Constructs a newConfigurationSourcewith the specified input stream that originated from the specified file.ConfigurationSource(InputStream stream, URL url) Constructs a newConfigurationSourcewith the specified input stream that originated from the specified URL.ConfigurationSource(InputStream stream, URL url, long lastModified) Constructs a newConfigurationSourcewith the specified input stream that originated from the specified URL.ConfigurationSource(InputStream stream, Path path) Constructs a newConfigurationSourcewith the specified input stream that originated from the specified path.ConfigurationSource(Source source, byte[] data, long lastModified) Constructs a newConfigurationSourcewith the specified source. -
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigurationSourcefromResource(String resource, ClassLoader loader) Retrieves the configuration via the ClassLoader.static ConfigurationSourceLoads the configuration from a URI.getFile()Returns the file configuration source, ornullif this configuration source is based on an URL or has neither a file nor an URL.Returns the input stream that this configuration source was constructed with.longReturns the last modification time known when theConfigurationSourcewas created.Returns a string describing the configuration source file or URL, ornullif this configuration source has neither a file nor an URL.getURI()Returns a URI representing the configuration resource or null if it cannot be determined.getURL()Returns the configuration source URL, ornullif this configuration source is based on a file or has neither a file nor an URL.Returns a newConfigurationSourcewhose input stream is reset to the beginning.voidsetData(byte[] data) voidsetModifiedMillis(long currentLastModified) Updates the last known modification time of the resource.voidDeprecated.Not used internally, no replacement.toString()
-
Field Details
-
NULL_SOURCE
ConfigurationSource to use with Configurations that do not require a "real" configuration source. -
COMPOSITE_SOURCE
ConfigurationSource to use withCompositeConfiguration.
-
-
Constructor Details
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified input stream that originated from the specified file.- Parameters:
stream- the input stream, the caller is responsible for closing this resource.file- the file where the input stream originated
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified input stream that originated from the specified path.- Parameters:
stream- the input stream, the caller is responsible for closing this resource.path- the path where the input stream originated.
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified input stream that originated from the specified URL.- Parameters:
stream- the input stream, the caller is responsible for closing this resource.url- the URL where the input stream originated
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified input stream that originated from the specified URL.- Parameters:
stream- the input stream, the caller is responsible for closing this resource.url- the URL where the input stream originatedlastModified- when the source was last modified.
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified input stream. Since the stream is the only source of data, this constructor makes a copy of the stream contents.- Parameters:
stream- the input stream, the caller is responsible for closing this resource.- Throws:
IOException- if an exception occurred reading from the specified stream
-
ConfigurationSource
Constructs a newConfigurationSourcewith the specified source.- Parameters:
source- a Source.data- data from the sourcelastModified- when the source was last modified.
-
-
Method Details
-
getFile
Returns the file configuration source, ornullif this configuration source is based on an URL or has neither a file nor an URL.- Returns:
- the configuration source file, or
null
-
getURL
Returns the configuration source URL, ornullif this configuration source is based on a file or has neither a file nor an URL.- Returns:
- the configuration source URL, or
null
-
setSource
Deprecated.Not used internally, no replacement. -
setData
public void setData(byte[] data) -
setModifiedMillis
public void setModifiedMillis(long currentLastModified) Updates the last known modification time of the resource.- Parameters:
currentLastModified- The modification time of the resource in millis.
-
getURI
Returns a URI representing the configuration resource or null if it cannot be determined.- Returns:
- The URI.
-
getLastModified
public long getLastModified()Returns the last modification time known when theConfigurationSourcewas created.- Returns:
- the last modified time of the resource.
-
getLocation
Returns a string describing the configuration source file or URL, ornullif this configuration source has neither a file nor an URL.- Returns:
- a string describing the configuration source file or URL, or
null
-
getInputStream
Returns the input stream that this configuration source was constructed with.- Returns:
- the input stream that this configuration source was constructed with.
-
resetInputStream
Returns a newConfigurationSourcewhose input stream is reset to the beginning.- Returns:
- a new
ConfigurationSource - Throws:
IOException- if a problem occurred while opening the new input stream
-
toString
-
fromUri
Loads the configuration from a URI.- Parameters:
configLocation- A URI representing the location of the configuration.- Returns:
- The ConfigurationSource for the configuration or
null.
-
fromResource
Retrieves the configuration via the ClassLoader.- Parameters:
resource- The resource to load.loader- The default ClassLoader to use.- Returns:
- The ConfigurationSource for the configuration.
-