亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

備忘錄三:Spring Boot+Druid+log4j2

發布時間:2020-08-10 16:26:11 來源:ITPUB博客 閱讀:232 作者:百聯達 欄目:編程語言

一:pom.xml配置:去掉Spring boot 默認的spring-boot-starter-logging,引入spring-boot-starter-log4j2

<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
		</dependency>


二:應用配置application.yaml

# logging
logging:
  config: classpath:log4j2.xml

三:log42j.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="OFF">
	<Properties>
		<property name="LOG_HOME">D:/logs</property>
	</Properties>
	<Appenders>
		<Console name="console" target="SYSTEM_OUT" immediateFlush="true">
			<ThresholdFilter level="debug" onMatch="ACCEPT"
				onMismatch="DENY" />
			<PatternLayout pattern="[%-5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] %c - %m%n" />
		</Console>
		<RollingRandomAccessFile name="infoLog"
			immediateFlush="true" fileName="${LOG_HOME}/infoService.log"
			filePattern="${LOG_HOME}/infoService.log.%d{yyyy-MM-dd}.log.gz">
			<PatternLayout>
				<pattern>[%-5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] %c - %m%n</pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
			<DefaultRolloverStrategy>
				<Delete basePath="${LOG_HOM}" maxDepth="1">
					<IfFileName glob="infoService*.gz" />
					<IfLastModified age="7d" />
				</Delete>
			</DefaultRolloverStrategy>
			<ThresholdFilter level="info" onMatch="ACCEPT"
				onMismatch="DENY" />
		</RollingRandomAccessFile>
		<RollingRandomAccessFile name="errorLog"
			immediateFlush="true" fileName="${LOG_HOME}/errorService.log"
			filePattern="${LOG_HOME}/errorService.log.%d{yyyy-MM-dd}.log.gz">
			<PatternLayout>
				<pattern>[%-5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] %c - %m%n</pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
			<DefaultRolloverStrategy>
				<Delete basePath="${LOG_HOM}" maxDepth="1">
					<IfFileName glob="errorService*.gz" />
					<IfLastModified age="7d" />
				</Delete>
			</DefaultRolloverStrategy>
			<ThresholdFilter level="error" onMatch="ACCEPT"
				onMismatch="DENY" />
		</RollingRandomAccessFile>
		<RollingRandomAccessFile name="fatalLog"
			immediateFlush="true" fileName="${LOG_HOME}/fatalService.log"
			filePattern="${LOG_HOME}/fatalService.log.%d{yyyy-MM-dd}.log.gz">
			<PatternLayout>
				<pattern>[%-5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] %c - %m%n</pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
			<DefaultRolloverStrategy>
				<Delete basePath="${LOG_HOM}" maxDepth="1">
					<IfFileName glob="fatalService*.gz" />
					<IfLastModified age="7d" />
				</Delete>
			</DefaultRolloverStrategy>
			<ThresholdFilter level="fatal" onMatch="ACCEPT"
				onMismatch="DENY" />
		</RollingRandomAccessFile>
		<RollingRandomAccessFile name="druidSqlLog"
			immediateFlush="true" fileName="${LOG_HOME}/druidSql.log"
			filePattern="${LOG_HOME}/druidSql.log.%d{yyyy-MM-dd}.log.gz">
			<PatternLayout>
				<pattern>[%-5p] [%d{yyyy-MM-dd HH:mm:ss SSS}] %c - %m%n</pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
			<DefaultRolloverStrategy>
				<Delete basePath="${LOG_HOM}" maxDepth="1">
					<IfFileName glob="druidSql*.gz" />
					<IfLastModified age="7d" />
				</Delete>
			</DefaultRolloverStrategy>
		</RollingRandomAccessFile>
	</Appenders>
	<Loggers>
		<!-- 根logger的設置 -->
		<root level="info">
			<appender-ref ref="console" />
			<appender-ref ref="infoLog" />
			<appender-ref ref="errorLog" />
			<appender-ref ref="fatalLog" />
		</root>
		<logger name="druid.sql.Statement" level="debug" additivity="false">
			<appender-ref ref="druidSqlLog" />
		</logger>
		<logger name="druid.sql.ResultSet" level="debug" additivity="false">
			<appender-ref ref="druidSqlLog" />
		</logger>
	</Loggers>
</Configuration>

四:Druid配置

mysql,druid
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/upin_charge?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
    username: username: 
    password: password: 
    druid:
      # 連接池的配置信息
      initial-size: 10
      max-active: 100
      min-idle: 10
      max-wait: 60000
      # 打開PSCache,并且指定每個連接上PSCache的大小 
      pool-prepared-statements: true 
      max-pool-prepared-statement-per-connection-size: 20
      # 配置間隔多久才進行一次檢測,檢測需要關閉的空閑連接,單位是毫秒
      time-between-eviction-runs-millis: 60000
      # 配置一個連接池中最小生存的時間,單位是毫秒
      min-evictable-idle-time-millis: 300000
      validation-query: SELECT 1 FROM DUAL
      test-while-idle: true
      test-on-borrow: false
      test-on-return: false
      #配置DruidStatViewServlet
      stat-view-servlet:
        enabled: true
        url-pattern: /druid/*
        #login-username: admin
        #login-password: admin
#      # 配置監控統計攔截的filters,去掉后,監控界面sql無法統計,'wall'用于防火墻
      filters: stat,wall,log4j2
      filter:
        stat:
          log-slow-sql: true
          slow-sql-millis: 1000
          merge-sql: true
        wall:
          config:
            multi-statement-allow: true
        log4j2:
            enabled: true
            result-set-log-enabled: true
            statement-executable-sql-log-enable: true
            statement-create-after-log-enabled: false
            statement-close-after-log-enabled: false
            result-set-open-after-log-enabled: false
            result-set-close-after-log-enabled: false

五:日志文件查看

備忘錄三:Spring Boot+Druid+log4j2

[DEBUG] [2019-08-06 16:58:20 570] druid.sql.Statement - {conn-10010, pstmt-20000} created. SELECT  push_id,uuid,user_id,user_name,msg_type,msg_object,msg_title,msg_content,status,read_status,read_date,receive_date,receive_user_id,create_date  FROM upin_msg.msg_push_info 
 WHERE  status='01'
[DEBUG] [2019-08-06 16:58:20 577] druid.sql.Statement - {conn-10010, pstmt-20000} Parameters : []
[DEBUG] [2019-08-06 16:58:20 577] druid.sql.Statement - {conn-10010, pstmt-20000} Types : []
[DEBUG] [2019-08-06 16:58:20 595] druid.sql.Statement - {conn-10010, pstmt-20000} executed. SELECT  push_id,uuid,user_id,user_name,msg_type,msg_object,msg_title,msg_content,status,read_status,read_date,receive_date,receive_user_id,create_date  FROM upin_msg.msg_push_info 
 WHERE  status='01'
[DEBUG] [2019-08-06 16:58:20 595] druid.sql.Statement - {conn-10010, pstmt-20000} executed. 19.4173 millis. SELECT  push_id,uuid,user_id,user_name,msg_type,msg_object,msg_title,msg_content,status,read_status,read_date,receive_date,receive_user_id,create_date  FROM upin_msg.msg_push_info 
 WHERE  status='01'
[DEBUG] [2019-08-06 16:58:20 601] druid.sql.ResultSet - {conn-10010, pstmt-20000, rs-50000} Result: [2, null, 1, test, 01, test, null, test, 01, 00, null, null, null, 2019-08-05 13:41:12.0]
[DEBUG] [2019-08-06 16:58:20 603] druid.sql.ResultSet - {conn-10010, pstmt-20000, rs-50000} Result: [3, null, 1, test, 01, test, null, test, 01, 00, null, null, null, 2019-08-05 13:52:05.0]
[DEBUG] [2019-08-06 16:58:20 603] druid.sql.ResultSet - {conn-10010, pstmt-20000, rs-50000} Result: [4, null, 1, test, 01, test, null, test, 01, 00, null, null, null, 2019-08-05 13:53:50.0]
[DEBUG] [2019-08-06 16:58:20 603] druid.sql.ResultSet - {conn-10010, pstmt-20000, rs-50000} Result: [5, null, 1, test, 01, test, null, test, 01, 00, null, null, null, 2019-08-06 10:41:10.0]
[DEBUG] [2019-08-06 16:58:20 604] druid.sql.ResultSet - {conn-10010, pstmt-20000, rs-50000} Result: [6, null, 1, test, 01, test, null, test, 01, 00, null, null, null, 2019-08-06 13:49:58.0]
[DEBUG] [2019-08-06 16:58:20 605] druid.sql.Statement - {conn-10010, pstmt-20000} clearParameters. 
[DEBUG] [2019-08-06 16:58:20 608] druid.sql.Statement - {conn-10010, pstmt-20000} Parameters : []
[DEBUG] [2019-08-06 16:58:20 608] druid.sql.Statement - {conn-10010, pstmt-20000} Types : []


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

碌曲县| 湖南省| 奇台县| 虎林市| 维西| 合肥市| 宁乡县| 温泉县| 康平县| 周宁县| 诸暨市| 民和| 宜都市| 凤凰县| 衡阳县| 宁强县| 永德县| 乌苏市| 如东县| 花垣县| 西昌市| 西充县| 密山市| 七台河市| 申扎县| 随州市| 巧家县| 舒城县| 贵定县| 鹿邑县| 大田县| 加查县| 克山县| 姚安县| 金平| 玛纳斯县| 雷山县| 呼和浩特市| 徐水县| 奉节县| 大荔县|