Skip to content

Commit

Permalink
Fixes qos-ch#39 (missing configuration files in Spring).
Browse files Browse the repository at this point in the history
  • Loading branch information
jgibson committed Feb 16, 2016
1 parent 2941026 commit 266fdb9
Showing 1 changed file with 19 additions and 1 deletion.
Expand Up @@ -17,6 +17,8 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import org.slf4j.impl.StaticLoggerBinder;
Expand Down Expand Up @@ -62,13 +64,29 @@ private LogbackConfigurer() {
* (e.g. "classpath:logback.xml"), an absolute file URL
* (e.g. "file:C:/logback.xml), or a plain absolute path in the file system
* (e.g. "C:/logback.xml")
* @throws java.io.FileNotFoundException if the location specifies an invalid file path
* @throws java.io.FileNotFoundException if the location is not found or if the location specifies an invalid file path
* @throws ch.qos.logback.core.joran.spi.JoranException
* Thrown
*/
public static void initLogging(String location) throws FileNotFoundException, JoranException {
String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
URL url = ResourceUtils.getURL(resolvedLocation);
InputStream check = null;
try {
check = url.openStream();
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
// Ignore and let the configuration continue in case Logback can handle it successfully
} finally {
if (check != null) {
try {
check.close();
} catch (IOException e) {
// We can probably eat this safely and let Logback trip the error
}
}
}
LoggerContext loggerContext = (LoggerContext)StaticLoggerBinder.getSingleton().getLoggerFactory();

// in the current version logback automatically configures at startup the context, so we have to reset it
Expand Down

0 comments on commit 266fdb9

Please sign in to comment.