Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
civil-bigdata
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
civil
civil-bigdata
Commits
0b4f6d0d
Commit
0b4f6d0d
authored
Sep 10, 2021
by
袁伟铭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除日志配置
parent
1ca72d3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
7 deletions
+100
-7
config-server/src/main/resources/properties/config-product.yml
+2
-2
resource-server/src/main/java/com/zq/resource/utils/ShareApiUtils.java
+5
-5
resource-server/src/main/resources/logback-spring.xml
+93
-0
No files found.
config-server/src/main/resources/properties/config-product.yml
View file @
0b4f6d0d
...
...
@@ -79,6 +79,6 @@ share:
#应用app-secret
app-secret
:
7774049b-3c89-4a20-8d4f-6bdfa972e86e
#API地址
api-url
:
http://
59.211.219.66:8081
api-url
:
http://
192.168.0.253:9066
#token获取接口
token-url
:
http://
59.211.219.66:8081
/epoint-sso-web/rest/oauth2/token
token-url
:
http://
192.168.0.253:9066
/epoint-sso-web/rest/oauth2/token
resource-server/src/main/java/com/zq/resource/utils/ShareApiUtils.java
View file @
0b4f6d0d
...
...
@@ -42,7 +42,7 @@ public class ShareApiUtils {
String
token
=
redisUtils
.
getStr
(
"shareApiAuthorization"
);
if
(
StringUtils
.
isNotBlank
(
token
))
{
headers
.
put
(
"Authorization"
,
token
);
headers
.
put
(
"Authorization"
,
"Bearer "
+
token
);
}
else
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"grant_type"
,
"client_credentials"
);
...
...
@@ -50,7 +50,7 @@ public class ShareApiUtils {
params
.
put
(
"client_id"
,
shareApiConfig
.
getAppKey
());
params
.
put
(
"client_secret"
,
shareApiConfig
.
getAppSecret
());
log
.
debug
(
"获取token-请求URL: {}"
,
shareApiConfig
.
getTokenUrl
());
log
.
debug
(
"获取token
请求
: {}"
,
JSON
.
toJSONString
(
params
));
log
.
debug
(
"获取token
-请求参数
: {}"
,
JSON
.
toJSONString
(
params
));
String
result
=
HttpRequest
.
post
(
shareApiConfig
.
getTokenUrl
())
.
formStr
(
params
)
...
...
@@ -65,7 +65,7 @@ public class ShareApiUtils {
if
(
"1"
.
equals
(
code
))
{
JSONObject
custom
=
jobj
.
getJSONObject
(
"custom"
);
token
=
jobj
.
getJSONObject
(
"custom"
).
getString
(
"access_token"
);
headers
.
put
(
"Authorization"
,
token
);
headers
.
put
(
"Authorization"
,
"Bearer "
+
token
);
redisUtils
.
setStr
(
"shareApiAuthorization"
,
token
,
custom
.
getLong
(
"expires_in"
)
-
10
,
TimeUnit
.
SECONDS
);
}
...
...
@@ -100,7 +100,7 @@ public class ShareApiUtils {
public
static
ShareApiResponse
doPost
(
Map
<
String
,
Object
>
params
,
ShareApiEnum
apiEnum
,
boolean
isTipError
)
{
String
body
=
JSON
.
toJSONString
(
params
);
log
.
debug
(
apiEnum
.
getLabel
()
+
"-请求URL: {}"
,
shareApiConfig
.
getApiUrl
()
+
apiEnum
.
getUrl
());
log
.
debug
(
apiEnum
.
getLabel
()
+
"-请求: {}"
,
body
);
log
.
debug
(
apiEnum
.
getLabel
()
+
"-请求
参数
: {}"
,
body
);
String
result
=
HttpRequest
.
post
(
shareApiConfig
.
getApiUrl
()
+
apiEnum
.
getUrl
())
.
body
(
body
)
.
header
(
"Content-Type"
,
"application/json;charset=utf-8"
)
...
...
@@ -111,7 +111,7 @@ public class ShareApiUtils {
ShareApiResponse
shareApiResponse
=
JSON
.
parseObject
(
result
,
ShareApiResponse
.
class
);
if
(
isTipError
)
{
AssertUtils
.
isTrue
(
shareApiResponse
.
isSuccess
(),
shareApiResponse
.
get
Error
());
AssertUtils
.
isTrue
(
shareApiResponse
.
isSuccess
(),
shareApiResponse
.
get
Message
());
}
return
shareApiResponse
;
...
...
resource-server/src/main/resources/logback-spring.xml
0 → 100644
View file @
0b4f6d0d
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--<include resource="org/springframework/boot/logging/logback/base.xml"/>-->
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/console-appender.xml"
/>
<property
name=
"default_log_path"
value=
"logs"
/>
<property
name=
"default_log_file"
value=
"resource"
/>
<!--主要日志文件名-->
<property
name=
"LOG_PATH"
value=
"${LOG_PATH:-${default_log_path}}"
/>
<property
name=
"LOG_FILE"
value=
"${LOG_FILE:-${default_log_file}}"
/>
<!-- the name of the application's logging context -->
<!-- by default each JMXConfigurator instance will be registered under the same name in the same JVM -->
<!-- we need to set the contextName for different apps, so that the jmxconfigurator won't collide -->
<contextName>
user
</contextName>
<jmxConfigurator/>
<!--主要日志配置 开始-->
<appender
name=
"SIZED_ROLLING_FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder>
<pattern>
%d %-5p [%t] %logger : %m%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<file>
${LOG_FILE}.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
10MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- 日志文档保留天数 -->
<maxHistory>
15
</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步输出 -->
<appender
name=
"main-logger-appender"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>
0
</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
512
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"SIZED_ROLLING_FILE"
/>
</appender>
<!--主要日志配置 结束-->
<!--共享平台接口日志配置 开始-->
<appender
name=
"SHARE_REQUEST_FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder>
<pattern>
%d %-5p [%t] %logger : %m%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<file>
share-api-request.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_PATH}/share-api-request.%d{yyyy-MM-dd}.%i.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
10MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- 日志文档保留天数 -->
<maxHistory>
15
</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步输出 -->
<appender
name=
"share-request-appender"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>
0
</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
512
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"SHARE_REQUEST_FILE"
/>
</appender>
<!--限流日志配置 结束-->
<!-- 多环境配置 按照active profile选择分支 -->
<springProfile
name=
"dev"
>
<logger
name=
"com.zq"
level=
"DEBUG"
/>
<root
level=
"INFO"
>
<appender-ref
ref=
"CONSOLE"
/>
</root>
</springProfile>
<springProfile
name=
"product"
>
<!--生产环境日志分开输出方便查找-->
<logger
name=
"com.zq"
level=
"INFO"
/>
<logger
name=
"com.zq.resource.utils.ShareApiUtils"
additivity=
"false"
level=
"DEBUG"
>
<appender-ref
ref=
"share-request-appender"
/>
</logger>
<root
level=
"INFO"
>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"main-logger-appender"
/>
</root>
</springProfile>
</configuration>
\ No newline at end of file
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