Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sh-ds
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李良停
sh-ds
Commits
ee6634a3
Commit
ee6634a3
authored
May 08, 2022
by
wangsong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change to log4j log
parent
09fa918f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
224 additions
and
10 deletions
+224
-10
pom.xml
eden-authcenter-agent/pom.xml
+19
-0
AuthController.java
...eall/eden/authcenter/agent/controller/AuthController.java
+3
-2
LogController.java
...seall/eden/authcenter/agent/controller/LogController.java
+33
-0
UcenterController.java
...l/eden/authcenter/agent/controller/UcenterController.java
+3
-2
application.yml
eden-authcenter-agent/src/main/resources/application.yml
+2
-0
bootstrap.yml
eden-authcenter-agent/src/main/resources/bootstrap.yml
+2
-0
dao-conf.json
eden-authcenter-agent/src/main/resources/dao-conf.json
+6
-6
log4j.xml
eden-authcenter-agent/src/main/resources/log4j.xml
+121
-0
pom.xml
eden-authcenter-log/pom.xml
+15
-0
BusinessLogUtils.java
...chineseall/eden/authcenter/log/util/BusinessLogUtils.java
+20
-0
No files found.
eden-authcenter-agent/pom.xml
View file @
ee6634a3
...
...
@@ -17,6 +17,25 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
<exclusions>
<!-- 排除自带的logback依赖 -->
<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>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/AuthController.java
View file @
ee6634a3
...
...
@@ -18,7 +18,8 @@ import com.chineseall.eden.authcenter.log.model.AuthLog;
import
com.chineseall.eden.authcenter.log.model.LogUserInfo
;
import
com.chineseall.eden.authcenter.log.service.AuthLogService
;
import
com.sh.chineseall.framework.core.http.resttemplate.MyRestTemplate
;
import
org.apache.log4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -39,7 +40,7 @@ import java.util.stream.Collectors;
@RequestMapping
(
"/"
)
public
class
AuthController
{
Logger
logger
=
Logger
.
getLogger
(
AuthController
.
class
);
Logger
logger
=
Logger
Factory
.
getLogger
(
AuthController
.
class
);
// @Autowired
// private OauthClient oauthClient;
...
...
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/LogController.java
0 → 100644
View file @
ee6634a3
package
com
.
chineseall
.
eden
.
authcenter
.
agent
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.chineseall.eden.authcenter.log.util.BusinessLogUtils
;
import
org.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
@Controller
@RequestMapping
(
"log"
)
public
class
LogController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LogController
.
class
);
@GetMapping
(
"test"
)
@ResponseBody
public
void
test
(
HttpServletRequest
request
){
Map
<
String
,
String
[]>
params
=
request
.
getParameterMap
();
BusinessLogUtils
.
info
(
params
);
logger
.
info
(
" ==== logs : "
+
JSON
.
toJSONString
(
params
));
}
}
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/UcenterController.java
View file @
ee6634a3
...
...
@@ -14,7 +14,8 @@ import com.chineseall.eden.authcenter.log.model.AuthLog;
import
com.chineseall.eden.authcenter.log.model.LogUserInfo
;
import
com.chineseall.eden.authcenter.log.service.AuthLogService
;
import
com.sh.chineseall.framework.core.http.resttemplate.MyRestTemplate
;
import
org.apache.log4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -38,7 +39,7 @@ import java.util.stream.Collectors;
@RequestMapping
(
"/ucenter"
)
public
class
UcenterController
{
Logger
logger
=
Logger
.
getLogger
(
UcenterController
.
class
);
Logger
logger
=
Logger
Factory
.
getLogger
(
UcenterController
.
class
);
@Autowired
private
OauthClient
oauthClient
;
...
...
eden-authcenter-agent/src/main/resources/application.yml
View file @
ee6634a3
server
:
port
:
9600
context-path
:
/authcenter
logging
:
config
:
classpath:log4j.xml
spring
:
application
:
name
:
eden-authcenter-agent
...
...
eden-authcenter-agent/src/main/resources/bootstrap.yml
View file @
ee6634a3
server
:
port
:
9600
context-path
:
/authcenter
logging
:
config
:
classpath:log4j.xml
spring
:
application
:
name
:
eden-authcenter-agent
...
...
eden-authcenter-agent/src/main/resources/dao-conf.json
View file @
ee6634a3
...
...
@@ -2,16 +2,16 @@
"mongo"
:
[
{
"connectionName"
:
"mongo"
,
"host"
:
"
dds-uf61aa933d7006b41.mongodb.rds.aliyuncs.com
"
,
"port"
:
37
17
,
"replicaSet"
:
"
dds-uf61aa933d7006b41.mongodb.rds.aliyuncs.com:37
17"
,
"host"
:
"
47.93.119.144
"
,
"port"
:
270
17
,
"replicaSet"
:
"
47.93.119.144:270
17"
,
"maxConnectionsPerHost"
:
3000
,
"threadsAllowedToBlockForConnectionMultiplier"
:
10
,
"authentication"
:
true
,
"connectTimeout"
:
10000
,
"password"
:
"
ChineseAll&0219
"
,
"userName"
:
"
dsuser
"
,
"dbName"
:
"
dslog
"
"password"
:
"
yuchu666
"
,
"userName"
:
"
admin
"
,
"dbName"
:
"
admin
"
}
]
}
\ No newline at end of file
eden-authcenter-agent/src/main/resources/log4j.xml
0 → 100644
View file @
ee6634a3
<?xml version="1.0" encoding="UTF-8"?>
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出-->
<!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
<configuration
monitorInterval=
"5"
>
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
<!--变量配置-->
<Properties>
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
<property
name=
"LOG_PATTERN"
value=
"%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
/>
<!-- 定义日志存储的路径 -->
<property
name=
"FILE_PATH"
value=
"/Users/wangsong/data/logs/"
/>
<property
name=
"FILE_NAME"
value=
"info"
/>
<property
name=
"BUSINESS_FILE_NAME"
value=
"business_info"
/>
</Properties>
<appenders>
<console
name=
"Console"
target=
"SYSTEM_OUT"
>
<!--输出日志的格式-->
<PatternLayout
pattern=
"${LOG_PATTERN}"
/>
<!--控制台只输出level及其以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter
level=
"info"
onMatch=
"ACCEPT"
onMismatch=
"DENY"
/>
</console>
<!--文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,适合临时测试用-->
<File
name=
"Filelog"
fileName=
"${FILE_PATH}/test.log"
append=
"false"
>
<PatternLayout
pattern=
"${LOG_PATTERN}"
/>
</File>
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile
name=
"RollingFileInfo"
fileName=
"${FILE_PATH}/info.log"
filePattern=
"${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz"
>
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter
level=
"info"
onMatch=
"ACCEPT"
onMismatch=
"DENY"
/>
<PatternLayout
pattern=
"${LOG_PATTERN}"
/>
<Policies>
<!--interval属性用来指定多久滚动一次,1 天-->
<TimeBasedTriggeringPolicy
interval=
"1"
/>
<SizeBasedTriggeringPolicy
size=
"10MB"
/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy
max=
"300"
/>
</RollingFile>
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile
name=
"RollingBusinessFileInfo"
fileName=
"${FILE_PATH}/business_info.log"
filePattern=
"${FILE_PATH}/${BUSINESS_FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz"
>
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter
level=
"info"
onMatch=
"ACCEPT"
onMismatch=
"DENY"
/>
<PatternLayout
pattern=
"%msg%n"
/>
<Policies>
<!--interval属性用来指定多久滚动一次,1 天-->
<TimeBasedTriggeringPolicy
interval=
"1"
/>
<SizeBasedTriggeringPolicy
size=
"10MB"
/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy
max=
"300"
/>
</RollingFile>
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile
name=
"RollingFileWarn"
fileName=
"${FILE_PATH}/warn.log"
filePattern=
"${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz"
>
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter
level=
"warn"
onMatch=
"ACCEPT"
onMismatch=
"DENY"
/>
<PatternLayout
pattern=
"${LOG_PATTERN}"
/>
<Policies>
<!--interval属性用来指定多久滚动一次,1天-->
<TimeBasedTriggeringPolicy
interval=
"1"
/>
<SizeBasedTriggeringPolicy
size=
"10MB"
/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy
max=
"300"
/>
</RollingFile>
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile
name=
"RollingFileError"
fileName=
"${FILE_PATH}/error.log"
filePattern=
"${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz"
>
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter
level=
"error"
onMatch=
"ACCEPT"
onMismatch=
"DENY"
/>
<PatternLayout
pattern=
"${LOG_PATTERN}"
/>
<Policies>
<!--interval属性用来指定多久滚动一次,1天-->
<TimeBasedTriggeringPolicy
interval=
"1"
/>
<SizeBasedTriggeringPolicy
size=
"10MB"
/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy
max=
"300"
/>
</RollingFile>
</appenders>
<!--Logger节点用来单独指定日志的形式,比如要为指定包下的class指定不同的日志级别等。-->
<!--然后定义loggers,只有定义了logger并引入的appender,appender才会生效-->
<loggers>
<!--过滤掉spring和mybatis的一些无用的DEBUG信息-->
<logger
name=
"org.mongodb"
level=
"info"
additivity=
"false"
>
<AppenderRef
ref=
"Console"
/>
</logger>
<!-- 启动日志打到控制台 -->
<Logger
name=
"org.springframework"
level=
"info"
additivity=
"false"
>
<AppenderRef
ref=
"Console"
/>
</Logger>
<!--监控系统信息-->
<!--若是additivity设为false,则 子Logger 只会在自己的appender里输出,而不会在 父Logger 的appender里输出。-->
<Logger
name=
"com.chineseall.eden.authcenter.log.util.BusinessLogUtils"
level=
"info"
additivity=
"true"
>
<AppenderRef
ref=
"RollingBusinessFileInfo"
/>
</Logger>
<root
level=
"info"
>
<appender-ref
ref=
"Console"
/>
<appender-ref
ref=
"Filelog"
/>
<appender-ref
ref=
"RollingFileInfo"
/>
<appender-ref
ref=
"RollingFileWarn"
/>
<appender-ref
ref=
"RollingFileError"
/>
</root>
</loggers>
</configuration>
eden-authcenter-log/pom.xml
View file @
ee6634a3
...
...
@@ -15,6 +15,21 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
<exclusions>
<!-- 排除自带的logback依赖 -->
<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>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
...
...
eden-authcenter-log/src/main/java/com/chineseall/eden/authcenter/log/util/BusinessLogUtils.java
0 → 100644
View file @
ee6634a3
package
com
.
chineseall
.
eden
.
authcenter
.
log
.
util
;
import
cn.sh.chineseall.framework.core.util.MapUtils
;
import
com.alibaba.fastjson.JSON
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Map
;
public
class
BusinessLogUtils
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BusinessLogUtils
.
class
);
public
static
void
info
(
Map
<
String
,
String
[]>
data
){
if
(
MapUtils
.
isEmpty
(
data
)){
return
;
}
logger
.
info
(
JSON
.
toJSONString
(
data
));
}
}
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