Class ConfigurationSource
- java.lang.Object
-
- org.apache.logging.log4j.core.config.ConfigurationSource
-
public class ConfigurationSource extends java.lang.ObjectRepresents the source for the logging configuration.
-
-
Field Summary
Fields Modifier and Type Field Description static ConfigurationSourceNULL_SOURCEConfigurationSource to use with Configurations that do not require a "real" configuration source.
-
Constructor Summary
Constructors Constructor Description ConfigurationSource(java.io.InputStream stream)Constructs a newConfigurationSourcewith the specified input stream.ConfigurationSource(java.io.InputStream stream, java.io.File file)Constructs a newConfigurationSourcewith the specified input stream that originated from the specified file.ConfigurationSource(java.io.InputStream stream, java.net.URL url)Constructs a newConfigurationSourcewith the specified input stream that originated from the specified url.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfigurationSourcefromResource(java.lang.String resource, java.lang.ClassLoader loader)Retrieves the configuration via the ClassLoader.static ConfigurationSourcefromUri(java.net.URI configLocation)Loads the configuration from a URI.java.io.FilegetFile()Returns the file configuration source, ornullif this configuration source is based on an URL or has neither a file nor an URL.java.io.InputStreamgetInputStream()Returns the input stream that this configuration source was constructed with.java.lang.StringgetLocation()Returns a string describing the configuration source file or URL, ornullif this configuration source has neither a file nor an URL.java.net.URIgetURI()Returns a URI representing the configuration resource or null if it cannot be determined.java.net.URLgetURL()Returns the configuration source URL, ornullif this configuration source is based on a file or has neither a file nor an URL.ConfigurationSourceresetInputStream()Returns a newConfigurationSourcewhose input stream is reset to the beginning.java.lang.StringtoString()
-
-
-
Field Detail
-
NULL_SOURCE
public static final ConfigurationSource NULL_SOURCE
ConfigurationSource to use with Configurations that do not require a "real" configuration source.
-
-
Constructor Detail
-
ConfigurationSource
public ConfigurationSource(java.io.InputStream stream, java.io.File file)Constructs a newConfigurationSourcewith the specified input stream that originated from the specified file.- Parameters:
stream- the input streamfile- the file where the input stream originated
-
ConfigurationSource
public ConfigurationSource(java.io.InputStream stream, java.net.URL url)Constructs a newConfigurationSourcewith the specified input stream that originated from the specified url.- Parameters:
stream- the input streamurl- the URL where the input stream originated
-
ConfigurationSource
public ConfigurationSource(java.io.InputStream stream) throws java.io.IOExceptionConstructs 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- Throws:
java.io.IOException- if an exception occurred reading from the specified stream
-
-
Method Detail
-
getFile
public java.io.File 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
public java.net.URL 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
-
getURI
public java.net.URI getURI()
Returns a URI representing the configuration resource or null if it cannot be determined.- Returns:
- The URI.
-
getLocation
public java.lang.String 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
public java.io.InputStream getInputStream()
Returns the input stream that this configuration source was constructed with.- Returns:
- the input stream that this configuration source was constructed with.
-
resetInputStream
public ConfigurationSource resetInputStream() throws java.io.IOException
Returns a newConfigurationSourcewhose input stream is reset to the beginning.- Returns:
- a new
ConfigurationSource - Throws:
java.io.IOException- if a problem occurred while opening the new input stream
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fromUri
public static ConfigurationSource fromUri(java.net.URI configLocation)
Loads the configuration from a URI.- Parameters:
configLocation- A URI representing the location of the configuration.- Returns:
- The ConfigurationSource for the configuration.
-
fromResource
public static ConfigurationSource fromResource(java.lang.String resource, java.lang.ClassLoader loader)
Retrieves the configuration via the ClassLoader.- Parameters:
resource- The resource to load.loader- The default ClassLoader to use.- Returns:
- The ConfigurationSource for the configuration.
-
-