NutzCN Logo
问答 spring-boot+logback,有日志文件但是无内容
发布于 2518天前 作者 qq_99c1b36f 4142 次浏览 复制 上一个帖子 下一个帖子
标签:

@wendal 大神,又来麻烦你了。
我用的spring-boot,配的logback,项目启动后,控制台有日志,本地也有日志文件,但是里面没有内容,百度过,弄了半天,没找到原因,特来请教。

logging.config=classpath:config/log-dev.xml
server.port=9092
server.tomcat.uri-encoding=UTF-8

endpoints.shutdown.enabled=true
spring.pidfile=spring.pid

spring.datasource.name=test
spring.datasource.url=jdbc:mysql://192.168.0.243:3306/pointshop?allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.maxActive=200
spring.datasource.initialSize=20
spring.datasource.maxWait=60000
spring.datasource.minIdle=1
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery= select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=20

spring.viewReslove.order=0
spring.viewReslove.location=WEB-INF/jasper/jasper-defs.xml

# MULTIPART (MultipartProperties)
multipart.enabled=true
multipart.file-size-threshold=0
multipart.location=
multipart.max-file-size=100Mb
multipart.max-request-size=10Mb

# HTTP encoding (HttpEncodingProperties)
spring.http.encoding.enabled=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.force=true

# JACKSON
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss


#log
logging.level.org.mybatis=debug
logging.level.dao=debug

spring.mvc.favicon.enabled=false

#resources cache
spring.resources.cache-period=0
spring.resources.chain.cache=false

#spring aop
spring.aop.auto=true
spring.aop.proxy-target-class=true

#spring MVC  http://localhost:8080/analysis
spring.mvc.view.prefix=/WEB-INF/jsp
spring.mvc.view.suffix=.jsp

# REDIS (RedisProperties)
#spring.redis.host=redis1
spring.redis.hostName=192.168.0.240
spring.redis.password=123456
spring.redis.port=6379
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=2
spring.redis.pool.max-active=8
spring.redis.pool.max-wait=-1
#spring.redis.sentinel.master=mymaster
#spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs.
#spring.redis.cluster.nodes[0] = # 127.0.0.1:7379
#spring.redis.cluster.nodes[1] = # 127.0.0.1:7380
spring.redis.timeout=30000

#spring.detools dir which dir need to restart
#spring.devtools.restart.additional-paths=src/main/java
#spring.devtools.remote.secret=123
#action
evn.evnType=1

#ensure upload config.xml
evn.conf=1


dubbo.application.name=application_service_admin
dubbo.application.logger=slf4j
dubbo.annotation.package=com.hshy
dubbo.protocol.name=dubbo
dubbo.protocol.port=20902
dubbo.protocol.accessLog=true
dubbo.provider.timeout=600000
dubbo.provider.retries=1
dubbo.provider.delay=-1
dubbo.registr.protocol=zookeeper
#dubbo.registry.address=192.168.0.240:2181  
dubbo.registry.address=localhost:2181
dubbo.registry.register=true 
dubbo.registry.subscribe=true 
<?xml version="1.0" encoding="UTF-8"?> 
<configuration>
	<!-- 文件输出格式 -->  
    <property name="PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n" /> 
	<!-- 日志文件存放路径 -->
	<property name="LOG_HOME" value="E:/log/pointshop"/>

	<!--1. 控制台日志打印 -->
	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<layout class="ch.qos.logback.classic.PatternLayout">
			<Pattern>
				${PATTERN}
			</Pattern>
		</layout>
	</appender>
	
	<!--2. log日志文件 -->
	<appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Prudent>true</Prudent>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--日志文件输出的文件名-->
            <FileNamePattern>${LOG_HOME}/admin-%d{yyyy-MM-dd}.log</FileNamePattern>
            <!--日志文件保留天数-->
            <MaxHistory>100</MaxHistory>
        </rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
                ${PATTERN}
            </Pattern>
        </layout>
	</appender>

    <!--3. error日志文件 -->
	<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <File>${LOG_HOME}/admin-error.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/admin-error-%d{yyyyMMdd}.log.%i
            </fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>500MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <maxHistory>2</maxHistory>
        </rollingPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
            	${PATTERN}
            </Pattern>
        </layout>
    </appender>

	<logger level="info" name="com.hshy.pointshop.admin"  additivity="true">
		<appender-ref ref="STDOUT" />
		<appender-ref ref="LOG_FILE" />
		<appender-ref ref="ERROR_FILE" />
	</logger>

	<root level="info">
		<appender-ref ref="STDOUT" />
		<appender-ref ref="ERROR_FILE" />
	</root>
</configuration>
2 回复

不晓得spring boot的logback是怎样的,路过

看到properties没,第一行指定了日志配置文件就行了,其实和框架没多大关系。
重点看看我的logback xml

添加回复
请先登陆
回到顶部