java - Spring boot setup logging before spring application starts -


i have project need logging mechanism before start springapplication. how can achieve that?

i tried setup 1 logging mechanism (logmanager.getlogmanager().readconfiguration()), overridden when spring application starts.

basically want use same logging mechanism everywhere.

spring boot uses loggingapplicationlistener configure logging application. listener 1 of springapplication's default listeners. use own already-configure logging system, need configure springapplication doesn't have listener. example, remove unwanted listener, while retaining of other default listeners:

@springbootapplication public class customloggingapplication {      public static void main(string[] args) {                 springapplication application =                  new springapplication(customloggingapplication.class);          collection<applicationlistener<?>> listeners =                  new arraylist<applicationlistener<?>>();         (applicationlistener<?> listener: application.getlisteners()) {             if (!(listener instanceof loggingapplicationlistener)) {                 listeners.add(listener);             }         }         application.setlisteners(listeners);          application.run(args);     }  } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -