配置logback出现了logs相面没有webapps文件夹的问题。

来源:3-3 验证配置

慕粉1556544580

2018-12-05

老师您好!我的是在配置logback那出错了,跟咱们之前一位同学所遇见的问题相像。程序对了对没有错误,也没报错,也把项目从服务器中扔出去再加载回来好几次,问题依然没解决,甚至我重新启动了eclipse,问题依然没解决。图片描述图片描述
图片描述

写回答

3回答

翔仔

2018-12-05

同学好,先不用担心,直接复制粘贴我的,替换掉你的logback.xml配置,全部替换,并且替换掉pom 然后clean tomcat 重启 之后如果成功的话,再对比下和原先的差别

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	version="3.1" metadata-complete="true">
	<display-name>Archetype Created Web Application</display-name>
	<welcome-file-list>
		<welcome-file>aaa.jsp</welcome-file>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	<servlet>
		<servlet-name>Kaptcha</servlet-name>
		<servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
		<!-- 是否有边框 -->
		<init-param>
			<param-name>kaptcha.border</param-name>
			<param-value>no</param-value>
		</init-param>
		<!-- 字体颜色 -->
		<init-param>
			<param-name>kaptcha.textproducer.font.color</param-name>
			<param-value>red</param-value>
		</init-param>
		<!-- 图片宽度 -->
		<init-param>
			<param-name>kaptcha.image.width</param-name>
			<param-value>135</param-value>
		</init-param>
		<!-- 使用哪些字符生成验证码 -->
		<init-param>
			<param-name>kaptcha.textproducer.char.string</param-name>
			<param-value>ACDEFHKPRSTWX345679</param-value>
		</init-param>
		<!-- 图片高度 -->
		<init-param>
			<param-name>kaptcha.image.height</param-name>
			<param-value>50</param-value>
		</init-param>
		<!-- 字体大小 -->
		<init-param>
			<param-name>kaptcha.textproducer.font.size</param-name>
			<param-value>43</param-value>
		</init-param>		
		<!-- 干扰线的颜色 -->
		<init-param>
			<param-name>kaptcha.noise.color</param-name>
			<param-value>black</param-value>
		</init-param>
		<!-- 字符个数 -->
		<init-param>
			<param-name>kaptcha.textproducer.char.length</param-name>
			<param-value>4</param-value>
		</init-param>		
		<!-- 字体 -->
		<init-param>
			<param-name>kaptcha.textproducer.font.names</param-name>
			<param-value>Arial</param-value>
		</init-param>					
	</servlet>
	<servlet-mapping>
		<servlet-name>Kaptcha</servlet-name>
		<url-pattern>/Kaptcha</url-pattern>
	</servlet-mapping>
	<servlet>
		<servlet-name>spring-dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/spring-*.xml</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>spring-dispatcher</servlet-name>
		<!-- 默认匹配所有的请求 -->
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.imooc</groupId>
	<artifactId>o2o</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>o2o Maven Webapp</name>
	<url>http://maven.apache.org</url>
	<properties>
		<spring.version>4.3.7.RELEASE</spring.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>1.2.3</version>
		</dependency>
		<!-- Spring -->
		<!-- 1)包含Spring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类,是其它组件的基本核心 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 2)这个jar 文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean 以及进行Inversion of Control 
			/ Dependency Injection(IoC/DI)操作相关的所有类。如果应用只需基本的IoC/DI 支持,引入spring-core.jar 
			及spring-beans.jar 文件就可以了。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 3)这个jar 文件为Spring 核心提供了大量扩展。可以找到使用Spring ApplicationContext特性时所需的全部类,JDNI 
			所需的全部类,instrumentation组件以及校验Validation 方面的相关类。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 4) 这个jar 文件包含对Spring 对JDBC 数据访问进行封装的所有类。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 5) 为JDBC、Hibernate、JDO、JPA等提供的一致的声明式和编程式事务管理。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 6)Spring web 包含Web应用开发时,用到Spring框架时所需的核心类,包括自动载入WebApplicationContext特性的类、Struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 7)包含SpringMVC框架相关的所有类。 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- 8)Spring test 对JUNIT等测试框架的简单封装 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
			<scope>test</scope>
		</dependency>
		<!-- Servlet web -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
		</dependency>
		<!-- json解析 -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.8.7</version>
		</dependency>
		<!-- Map工具类 对标准java Collection的扩展 spring-core.jar需commons-collections.jar -->
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>3.2</version>
		</dependency>
		<!-- DAO: MyBatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.4.2</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.3.1</version>
		</dependency>
		<!-- 数据库 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.37</version>
		</dependency>
		<dependency>
			<groupId>c3p0</groupId>
			<artifactId>c3p0</artifactId>
			<version>0.9.1.2</version>
		</dependency>
		<!-- 图片处理 -->
		<!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator -->
		<dependency>
			<groupId>net.coobird</groupId>
			<artifactId>thumbnailator</artifactId>
			<version>0.4.8</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.github.penggle/kaptcha -->
		<dependency>
			<groupId>com.github.penggle</groupId>
			<artifactId>kaptcha</artifactId>
			<version>2.3.2</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.3.2</version>
		</dependency>
		<!-- redis客户端:Jedis -->
		<dependency>
			<groupId>redis.clients</groupId>
			<artifactId>jedis</artifactId>
			<version>2.9.0</version>
		</dependency>
	</dependencies>
	<build>
		<finalName>o2o</finalName>
		<plugins>
			<plugin>
				<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.1</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF8</encoding>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>


0
4
翔仔
回复
慕粉1556544580
同学好,问题也很明显啊,你如果复制我的pom和logback成功 用自己的不成功,肯定还是有差别的呀。。。可以用beyond compare来对比下logback以及pom的配置
2018-12-06
共4条回复

慕粉1556544580

提问者

2018-12-06

老师,这是我UPdate project 后的错误//img.mukewang.com/szimg/5c07feed00012cc913660729.jpg

0
0

慕粉1556544580

提问者

2018-12-06

老师这是我的logback.xml配置文件,我看也没问题啊!
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
	<!--定义参数常量  -->
	<!--TRACE<DEBUG<INFO<WARN<ERROR  -->
	<!-- logger.trace("msg")   logger.debug... -->
	<property name="log.level" value="debug"/>
	<property name="log.maxHistory" value="30"/>
	<property name="log.filePath" value="${catalina.base}/logs/webapps"/>
	<property name="log.pattern"
		 value="%d{yyyy-MM-dd HH:mm:ss.SSS}[%thread] %-5level %logger{50} - %msg%n"/>
	 <!-- 控制台设置 -->
	 <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
	 	<encoder>
	 		<pattern>${log.pattern}</pattern>
	 	</encoder>
	 </appender>
	 <!-- DEBUG -->
	 <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
	 	<!-- 文件路径 -->
	 	<file>${log.filePath/debug.log}</file>
	 	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	 		<!-- 文件名称 -->
	 		<fileNamePattern>${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gz	 		
	 		</fileNamePattern>
	 		<!-- 文件最大保存历史数量 -->
	 		<maxHistory>${log.maxHistory}</maxHistory>
	 	</rollingPolicy>
	 	<encoder>
	 		<pattern>${log.pattern}</pattern>
	 	</encoder>
	 	<filter class="ch.qos.logback.classic.filter.LevelFilter">
	 		<level>DEBUG</level>
	 		<onMatch>ACCEPT</onMatch>
	 		<onMismatch>DENY</onMismatch>
	 	</filter>
	 </appender>
	 <!-- INFO -->
	 <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
	 	<!-- 文件路径 -->
	 	<file>${log.filePath/info.log}</file>
	 	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	 		<!-- 文件名称 -->
	 		<fileNamePattern>${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz	 		
	 		</fileNamePattern>
	 		<!-- 文件最大保存历史数量 -->
	 		<maxHistory>${log.maxHistory}</maxHistory>
	 	</rollingPolicy>
	 	<encoder>
	 		<pattern>${log.pattern}</pattern>
	 	</encoder>
	 	<filter class="ch.qos.logback.classic.filter.LevelFilter">
	 		<level>INFO</level>
	 		<onMatch>ACCEPT</onMatch>
	 		<onMismatch>DENY</onMismatch>
	 	</filter>
	 </appender>
	  <!-- ERROR -->
	 <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
	 	<!-- 文件路径 -->
	 	<file>${log.filePath/error.log}</file>
	 	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	 		<!-- 文件名称 -->
	 		<fileNamePattern>${log.filePath}/error/error.%d{yyyy-MM-dd}.log.gz	 		
	 		</fileNamePattern>
	 		<!-- 文件最大保存历史数量 -->
	 		<maxHistory>${log.maxHistory}</maxHistory>
	 	</rollingPolicy>
	 	<encoder>
	 		<pattern>${log.pattern}</pattern>
	 	</encoder>
	 	<filter class="ch.qos.logback.classic.filter.LevelFilter">
	 		<level>ERROR</level>
	 		<onMatch>ACCEPT</onMatch>
	 		<onMismatch>DENY</onMismatch>
	 	</filter>
	 </appender>
	 <logger name="com.imooc.o2o" level="${log.level}" additivity="true">
	 	<appender-ref ref="debugAppender"/>
	 	<appender-ref ref="infoAppender"/>
	 	<appender-ref ref="errorAppender"/>
	 </logger>
	 <root level="info">
	 	<appender-ref ref="consoleAppender"/>
	 </root>
	 
</configuration>

0
0

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程