File tree Expand file tree Collapse file tree
jooby/src/main/java/org/jooby Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5757
5858import java .io .File ;
5959import java .lang .reflect .Type ;
60+ import java .net .URL ;
6061import java .nio .charset .Charset ;
6162import java .nio .file .Path ;
6263import java .nio .file .Paths ;
@@ -3196,11 +3197,17 @@ static String logback(final Config conf) {
31963197 if (conf .hasPath ("logback.configurationFile" )) {
31973198 logback = conf .getString ("logback.configurationFile" );
31983199 } else {
3200+ String env = conf .hasPath ("application.env" ) ? conf .getString ("application.env" ) : null ;
3201+ if (env != null ) {
3202+ URL classpathLogback = Thread .currentThread ().getContextClassLoader ().getResource ("logback." + env + ".xml" );
3203+ if (classpathLogback != null ) {
3204+ return classpathLogback .toString ();
3205+ }
3206+ }
31993207 ImmutableList .Builder <File > files = ImmutableList .builder ();
32003208 File userdir = new File (System .getProperty ("user.dir" ));
32013209 File confdir = new File (userdir , "conf" );
3202- if (conf .hasPath ("application.env" )) {
3203- String env = conf .getString ("application.env" );
3210+ if (env != null ) {
32043211 files .add (new File (userdir , "logback." + env + ".xml" ));
32053212 files .add (new File (confdir , "logback." + env + ".xml" ));
32063213 }
You can’t perform that action at this time.
0 commit comments