Commit be822bc3 authored by Administrator's avatar Administrator

2024.11.14 添加log4jdbc 日志

parent 1cd0ff8d
...@@ -48,13 +48,16 @@ ...@@ -48,13 +48,16 @@
<groupId>com.gemho</groupId> <groupId>com.gemho</groupId>
<artifactId>gemho-framework</artifactId> <artifactId>gemho-framework</artifactId>
</dependency> </dependency>
<!-- 定时任务--> <!-- 定时任务-->
<dependency> <dependency>
<groupId>com.gemho</groupId> <groupId>com.gemho</groupId>
<artifactId>gemho-quartz</artifactId> <artifactId>gemho-quartz</artifactId>
</dependency> </dependency>
<!--日志-->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
</dependency>
<!-- 代码生成--> <!-- 代码生成-->
<dependency> <dependency>
<groupId>com.gemho</groupId> <groupId>com.gemho</groupId>
......
...@@ -52,7 +52,7 @@ spring: ...@@ -52,7 +52,7 @@ spring:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: druid active: my
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
...@@ -66,27 +66,6 @@ spring: ...@@ -66,27 +66,6 @@ spring:
# 热部署开关 # 热部署开关
enabled: true enabled: true
# redis 配置 # redis 配置
redis:
# 地址
host: localhost
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# token配置 # token配置
token: token:
...@@ -113,6 +92,7 @@ mybatis-plus: ...@@ -113,6 +92,7 @@ mybatis-plus:
logic-delete-value: 2 logic-delete-value: 2
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
# PageHelper分页插件 # PageHelper分页插件
pagehelper: pagehelper:
......
# ????
log4jdbc.drivers=com.mysql.cj.jdbc.Driver
#???.?????????SQL???????warn??
log4jdbc.sqltiming.warn.threshold=2000
#???.?????????SQL???????error??
log4jdbc.sqltiming.error.threshold=3000
#??????SOL
log4jdbc.trim.sql=true
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
# ???????????
log4jdbc.auto.load.popular.drivers=false
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!--控制台输出内容的颜色转换以及格式-->
<substitutionProperty name="logging.pattern.console"
value="%contextName- %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %msg%n"/>
<!--日志文件输出内容的格式-->
<substitutionProperty name="logging.pattern.file"
value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!--控制台使用layout节点-->
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
${logging.pattern.console}
</pattern>
</layout>
</appender>
<!--按天生成日志-->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<!--滚动策略,我配置了按天生成日志文件-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--相对路径,生成的文件就在项目根目录下-->
<FileNamePattern>
logs/debug/%d{yyyy-MM}/%d{yyyy-MM-dd}.log
</FileNamePattern>
<!--注意超过365天的日志文件会被删除,即使已经按天分开也会删除-->
<MaxHistory>365</MaxHistory>
</rollingPolicy>
<!--日志文件里只保存ERROR及以上级别的日志-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<!--文件使用encoder节点-->
<encoder>
<Pattern>
${logging.pattern.file}
</Pattern>
</encoder>
</appender>
<!--按天生成日志-->
<appender name="errorfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<!--滚动策略,我配置了按天生成日志文件-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--相对路径,生成的文件就在项目根目录下-->
<FileNamePattern>
logs/error/%d{yyyy-MM}/%d{yyyy-MM-dd}.log
</FileNamePattern>
<!--注意超过365天的日志文件会被删除,即使已经按天分开也会删除-->
<MaxHistory>365</MaxHistory>
</rollingPolicy>
<!--日志文件里只保存ERROR及以上级别的日志-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<!--文件使用encoder节点-->
<encoder>
<Pattern>
${logging.pattern.file}
</Pattern>
</encoder>
</appender>
<!--这个logger里的配置相当于之前yml里的logging.level.com.lpc: trace-->
<!--additivity的作用-->
<!--true,则子Logger不止会在自己的appender里输出,还会在root的logger的appender里输出-->
<!--而这个logger里没配置appender,所以得交给root打印-->
<!--所以com.lpc包里的日志从TRACE级别开始-->
<!--其他包里的日志根据root的配置从INFO级别开始打印-->
<logger name="com.lpc" level="DEBUG" additivity="true">
</logger>
<!-- 如想看到表格数据,将OFF改为INFO -->
<logger name="jdbc.resultsettable" level="OFF" additivity="false">
<appender-ref ref="console"/>
</logger>
<logger name="jdbc.connection" level="OFF" additivity="false">
<appender-ref ref="console"/>
</logger>
<logger name="jdbc.sqltiming" level="OFF" additivity="false">
<appender-ref ref="console"/>
</logger>
<logger name="jdbc.audit" level="OFF" additivity="false">
<appender-ref ref="console"/>
</logger>
<logger name="jdbc.resultset" level="OFF" additivity="false">
<appender-ref ref="console"/>
</logger>
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="file"/>
<appender-ref ref="errorfile"/>
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/gemho/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</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>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</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>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.gemho" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<hutool.version>5.7.2</hutool.version> <hutool.version>5.7.2</hutool.version>
<mybatis-plus-spring-boot.version>3.5.7</mybatis-plus-spring-boot.version> <mybatis-plus-spring-boot.version>3.5.7</mybatis-plus-spring-boot.version>
<pagehelper.boot.version>2.1.0</pagehelper.boot.version> <pagehelper.boot.version>2.1.0</pagehelper.boot.version>
<log4jdbc.version>1.16</log4jdbc.version>
<fastjson.version>2.0.53</fastjson.version> <fastjson.version>2.0.53</fastjson.version>
<oshi.version>6.6.3</oshi.version> <oshi.version>6.6.3</oshi.version>
<commons.io.version>2.13.0</commons.io.version> <commons.io.version>2.13.0</commons.io.version>
...@@ -102,6 +103,12 @@ ...@@ -102,6 +103,12 @@
</exclusions> </exclusions>
<version>${pagehelper.boot.version}</version> <version>${pagehelper.boot.version}</version>
</dependency> </dependency>
<!--日志-->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
<version>${log4jdbc.version}</version>
</dependency>
<!-- 获取系统信息 --> <!-- 获取系统信息 -->
<dependency> <dependency>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment