Defer SpringBootServletInitializer getLog
Change `SpringBootServletInitializer` so that the logger is created in `onStartup` rather than on class creation. The allows logging to be initialized in an different WebApplicationInitializer. Fixes gh-3704
This commit is contained in:
		
							parent
							
								
									f02c651e40
								
							
						
					
					
						commit
						e0f62308bc
					
				| 
						 | 
				
			
			@ -62,7 +62,7 @@ import org.springframework.web.context.WebApplicationContext;
 | 
			
		|||
 */
 | 
			
		||||
public abstract class SpringBootServletInitializer implements WebApplicationInitializer {
 | 
			
		||||
 | 
			
		||||
	protected final Log logger = LogFactory.getLog(getClass());
 | 
			
		||||
	protected Log logger; // Don't initialize early
 | 
			
		||||
 | 
			
		||||
	private boolean registerErrorPageFilter = true;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,6 +78,9 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
 | 
			
		|||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onStartup(ServletContext servletContext) throws ServletException {
 | 
			
		||||
		// Logger initialization is deferred in case a ordered
 | 
			
		||||
		// LogServletContextInitializer is being used
 | 
			
		||||
		this.logger = LogFactory.getLog(getClass());
 | 
			
		||||
		WebApplicationContext rootAppContext = createRootApplicationContext(
 | 
			
		||||
				servletContext);
 | 
			
		||||
		if (rootAppContext != null) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue