Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
ServerModel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
kiritoausna
ServerModel
Commits
be822bc3
Commit
be822bc3
authored
Nov 14, 2024
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2024.11.14 添加log4jdbc 日志
parent
1cd0ff8d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
119 deletions
+133
-119
pom.xml
gemho-admin/pom.xml
+5
-2
application.yml
gemho-admin/src/main/resources/application.yml
+2
-22
log4jdbc.log4j2.properties
gemho-admin/src/main/resources/log4jdbc.log4j2.properties
+11
-0
logback-spring.xml
gemho-admin/src/main/resources/logback-spring.xml
+106
-0
logback.xml
gemho-admin/src/main/resources/logback.xml
+0
-93
pom.xml
pom.xml
+9
-2
No files found.
gemho-admin/pom.xml
View file @
be822bc3
...
...
@@ -48,13 +48,16 @@
<groupId>
com.gemho
</groupId>
<artifactId>
gemho-framework
</artifactId>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>
com.gemho
</groupId>
<artifactId>
gemho-quartz
</artifactId>
</dependency>
<!--日志-->
<dependency>
<groupId>
org.bgee.log4jdbc-log4j2
</groupId>
<artifactId>
log4jdbc-log4j2-jdbc4.1
</artifactId>
</dependency>
<!-- 代码生成-->
<dependency>
<groupId>
com.gemho
</groupId>
...
...
gemho-admin/src/main/resources/application.yml
View file @
be822bc3
...
...
@@ -52,7 +52,7 @@ spring:
# 国际化资源文件路径
basename
:
i18n/messages
profiles
:
active
:
druid
active
:
my
# 文件上传
servlet
:
multipart
:
...
...
@@ -66,27 +66,6 @@ spring:
# 热部署开关
enabled
:
true
# 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
:
...
...
@@ -113,6 +92,7 @@ mybatis-plus:
logic-delete-value
:
2
configuration
:
map-underscore-to-camel-case
:
true
log-impl
:
org.apache.ibatis.logging.nologging.NoLoggingImpl
# PageHelper分页插件
pagehelper
:
...
...
gemho-admin/src/main/resources/log4jdbc.log4j2.properties
0 → 100644
View file @
be822bc3
# ????
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
gemho-admin/src/main/resources/logback-spring.xml
0 → 100644
View file @
be822bc3
<?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>
gemho-admin/src/main/resources/logback.xml
deleted
100644 → 0
View file @
1cd0ff8d
<?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
pom.xml
View file @
be822bc3
...
...
@@ -2,8 +2,8 @@
<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/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.gemho
</groupId>
<artifactId>
gemho
</artifactId>
<version>
3.8.8
</version>
...
...
@@ -24,6 +24,7 @@
<hutool.version>
5.7.2
</hutool.version>
<mybatis-plus-spring-boot.version>
3.5.7
</mybatis-plus-spring-boot.version>
<pagehelper.boot.version>
2.1.0
</pagehelper.boot.version>
<log4jdbc.version>
1.16
</log4jdbc.version>
<fastjson.version>
2.0.53
</fastjson.version>
<oshi.version>
6.6.3
</oshi.version>
<commons.io.version>
2.13.0
</commons.io.version>
...
...
@@ -102,6 +103,12 @@
</exclusions>
<version>
${pagehelper.boot.version}
</version>
</dependency>
<!--日志-->
<dependency>
<groupId>
org.bgee.log4jdbc-log4j2
</groupId>
<artifactId>
log4jdbc-log4j2-jdbc4.1
</artifactId>
<version>
${log4jdbc.version}
</version>
</dependency>
<!-- 获取系统信息 -->
<dependency>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment