I have a log4j2.xml configuration file that should get the logging path dynamically set during startup of the web application by java code.
log4j2.xml:
<Properties>
<property name="path">{web:attr.logpath}</property>
</Properties>
Therefore I have the following configuration file:
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
public class LogConfig extends SpringBootServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(Log4jConfigListener.class);
servletContext.setAttribute("logpath", "d:/testpath");
super.onStartup(servletContext);
}
}
Problem: When onStartup()
is entered, the log4j initialization is already over and I get the message that log4j path is invalid.
How can I delay the log4j initialization after the attributes have been set?
Aucun commentaire:
Enregistrer un commentaire