protected static URL getUrlForStringFromClasspathAsFileOrUrl ( String logbackConfigurationFile ) { URL url = null ; try { url = Resources . getResource ( logbackConfigurationFile ) ; } catch ( IllegalArgumentException ex ) { // doing nothing intentionally.. } if ( url == null ) { // configuring from file: try { File file = new File ( logbackConfigurationFile ) ; if ( file . exists ( ) ) { url = new File ( logbackConfigurationFile ) . toURI ( ) . toURL ( ) ; } } catch ( MalformedURLException ex ) { // doing nothing intentionally.. } } if ( url == null ) { try { // we assume we got a real http://... url here... url = new URL ( logbackConfigurationFile ) ; } catch ( MalformedURLException ex ) { // doing nothing intentionally.. } } return url ; }
Looks up a potential file from 1 ) The classpahth 2 ) From the filesystem 3 ) From an URL