How to run a class before the initiation of SLF4J - Logback?

匿名 (未验证) 提交于 2019-12-03 09:18:39

问题:

As the title says, I want to run a class that will check if a property exists in a directory before the initiation of logback. So what I've tried is I put a listener that will fire at startup before the listener of spring and I've made sure that no Logger is used in this listener. But the Logger still manage to fire before my listeners. Here's my web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xmlns="http://java.sun.com/xml/ns/javaee"          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"          metadata-complete="false"          version="3.0"           id="WebApp_ID" >      <display-name>SekaiServer</display-name>  <!-- My listeners -->    <listener>     <listener-class>listener.InitLog</listener-class>   </listener>    <listener>     <listener-class>listener.InitConfig</listener-class>   </listener>    <listener>     <listener-class>listener.InitListener</listener-class>   </listener>     <!--         - Location of the XML file that defines the root application context.         - Applied by ContextLoaderListener.     -->     <context-param>         <param-name>contextConfigLocation</param-name>         <param-value>         classpath:spring/application-config.xml         /WEB-INF/security-context.xml         </param-value>     </context-param>       <listener>         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>     </listener>       <!--         - Servlet that dispatches request to registered handlers (Controller implementations).     -->     <servlet>         <servlet-name>dispatcherServlet</servlet-name>         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>         <init-param>             <param-name>contextConfigLocation</param-name>             <param-value>/WEB-INF/mvc-config.xml</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>dispatcherServlet</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>      <!-- Spring Security -->     <filter>         <filter-name>springSecurityFilterChain</filter-name>         <filter-class>org.springframework.web.filter.DelegatingFilterProxy         </filter-class>     </filter>      <filter-mapping>         <filter-name>springSecurityFilterChain</filter-name>         <url-pattern>/*</url-pattern>     </filter-mapping>    </web-app>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!