1919import java .util .LinkedHashMap ;
2020import java .util .Map ;
2121
22+ import org .apache .commons .logging .Log ;
23+
2224import org .springframework .boot .context .event .ApplicationPreparedEvent ;
2325import org .springframework .boot .logging .DeferredLog ;
2426import org .springframework .context .ApplicationListener ;
3234 */
3335public final class DevToolsLogFactory {
3436
35- private static final Map <DeferredLog , Class <?>> logs = new LinkedHashMap <>();
37+ private static final Map <Log , Class <?>> logs = new LinkedHashMap <>();
3638
3739 private DevToolsLogFactory () {
3840 }
3941
4042 /**
41- * Get a {@link DeferredLog } instance for the specified source that will be
42- * automatically {@link DeferredLog#switchTo(Class) switched} then the
43- * {@link AbstractPageRequest context is prepared}.
43+ * Get a {@link Log } instance for the specified source that will be automatically
44+ * {@link DeferredLog#switchTo(Class) switched} then the {@link AbstractPageRequest
45+ * context is prepared}.
4446 * @param source the source for logging
4547 * @return a {@link DeferredLog} instance
4648 */
47- public static DeferredLog getLog (Class <?> source ) {
49+ public static Log getLog (Class <?> source ) {
4850 synchronized (logs ) {
49- DeferredLog log = new DeferredLog ();
51+ Log log = new DeferredLog ();
5052 logs .put (log , source );
5153 return log ;
5254 }
@@ -60,7 +62,11 @@ static class Listener implements ApplicationListener<ApplicationPreparedEvent> {
6062 @ Override
6163 public void onApplicationEvent (ApplicationPreparedEvent event ) {
6264 synchronized (logs ) {
63- logs .forEach ((log , source ) -> log .switchTo (source ));
65+ logs .forEach ((log , source ) -> {
66+ if (log instanceof DeferredLog ) {
67+ ((DeferredLog ) log ).switchTo (source );
68+ }
69+ });
6470 logs .clear ();
6571 }
6672 }
0 commit comments