如果需要自定义位置,需要在上面的web.xml中添加以下代码
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <context-param> <param-name>log4jConfiguration</param-name> <param-value>classpath:log4j2.xml</param-value> </context-param> import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Main { private static final Logger logger = LoggerFactory.getLogger(Main.class); public static void main(String[] args) { String world = "world"; logger.info("hellp world:{}",world); logger.error("exception e"); } }Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx