Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
cf68a533
Commit
cf68a533
authored
Aug 09, 2019
by
QIANGLU
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev'
parents
6b053ac5
71f27b11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
2 deletions
+82
-2
pom.xml
logger-starter/secoo-log-starter/pom.xml
+15
-0
MatrixApplicationRunner.java
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/boot/MatrixApplicationRunner.java
+24
-0
MatrixLogListenerConfiguration.java
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/config/MatrixLogListenerConfiguration.java
+14
-2
LogEndpoint.java
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/endpoint/LogEndpoint.java
+29
-0
HttpClientUtils.java
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/utils/HttpClientUtils.java
+0
-0
No files found.
logger-starter/secoo-log-starter/pom.xml
View file @
cf68a533
...
@@ -31,6 +31,20 @@
...
@@ -31,6 +31,20 @@
<artifactId>
apollo-client
</artifactId>
<artifactId>
apollo-client
</artifactId>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-actuator-autoconfigure
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.5
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/boot/MatrixApplicationRunner.java
0 → 100644
View file @
cf68a533
package
com
.
secoo
.
mall
.
logs
.
boot
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.util.StringUtils
;
/**
* 用于启动后数据加载
* @author qianglu
*/
public
class
MatrixApplicationRunner
implements
ApplicationRunner
{
private
String
url
;
public
MatrixApplicationRunner
(
String
url
)
{
if
(!
StringUtils
.
isEmpty
(
url
)){
this
.
url
=
url
;
}
}
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
}
}
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/config/MatrixLogListenerConfiguration.java
View file @
cf68a533
...
@@ -5,12 +5,16 @@ import com.ctrip.framework.apollo.model.ConfigChangeEvent;
...
@@ -5,12 +5,16 @@ import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.boot.ApolloAutoConfiguration
;
import
com.ctrip.framework.apollo.spring.boot.ApolloAutoConfiguration
;
import
com.secoo.mall.logs.endpoint.LogEndpoint
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.logging.LoggingSystem
;
import
org.springframework.boot.logging.LoggingSystem
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -19,6 +23,7 @@ import java.util.Set;
...
@@ -19,6 +23,7 @@ import java.util.Set;
/**
/**
* 用于提供动态日志切换
* 用于提供动态日志切换
*
* @author qianglu
* @author qianglu
*/
*/
@Configuration
@Configuration
...
@@ -44,11 +49,11 @@ public class MatrixLogListenerConfiguration implements InitializingBean {
...
@@ -44,11 +49,11 @@ public class MatrixLogListenerConfiguration implements InitializingBean {
private
void
refreshLoggingLevels
()
{
private
void
refreshLoggingLevels
()
{
Set
<
String
>
keyNames
=
config
.
getPropertyNames
();
Set
<
String
>
keyNames
=
config
.
getPropertyNames
();
for
(
String
key
:
keyNames
)
{
for
(
String
key
:
keyNames
)
{
if
(
StringUtils
.
startsWithIgnoreCase
(
key
,
LOGGER_TAG
))
{
if
(
StringUtils
.
startsWithIgnoreCase
(
key
,
LOGGER_TAG
))
{
String
strLevel
=
config
.
getProperty
(
key
,
"info"
);
String
strLevel
=
config
.
getProperty
(
key
,
"info"
);
LogLevel
level
=
LogLevel
.
valueOf
(
strLevel
.
toUpperCase
());
LogLevel
level
=
LogLevel
.
valueOf
(
strLevel
.
toUpperCase
());
loggingSystem
.
setLogLevel
(
key
.
replace
(
LOGGER_TAG
,
""
),
level
);
loggingSystem
.
setLogLevel
(
key
.
replace
(
LOGGER_TAG
,
""
),
level
);
logger
.
info
(
"update class {} logger level to {}"
,
key
,
strLevel
);
logger
.
info
(
"update class {} logger level to {}"
,
key
,
strLevel
);
}
}
}
}
}
}
...
@@ -58,4 +63,11 @@ public class MatrixLogListenerConfiguration implements InitializingBean {
...
@@ -58,4 +63,11 @@ public class MatrixLogListenerConfiguration implements InitializingBean {
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
throws
Exception
{
refreshLoggingLevels
();
refreshLoggingLevels
();
}
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
public
LogEndpoint
logEndpoint
()
{
return
new
LogEndpoint
();
}
}
}
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/endpoint/LogEndpoint.java
0 → 100644
View file @
cf68a533
package
com
.
secoo
.
mall
.
logs
.
endpoint
;
import
ch.qos.logback.classic.Logger
;
import
ch.qos.logback.classic.LoggerContext
;
import
org.slf4j.impl.StaticLoggerBinder
;
import
org.springframework.boot.actuate.endpoint.annotation.Endpoint
;
import
org.springframework.boot.actuate.endpoint.annotation.ReadOperation
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* @author qianglu
*/
@Endpoint
(
id
=
"matrixlog"
)
public
class
LogEndpoint
{
@ReadOperation
public
List
<
String
>
matrixlog
()
{
List
<
String
>
result
=
new
LinkedList
<>();
LoggerContext
factory
=
(
LoggerContext
)
StaticLoggerBinder
.
getSingleton
().
getLoggerFactory
();
List
<
Logger
>
li
=
factory
.
getLoggerList
();
li
.
forEach
(
logs
->
result
.
add
(
logs
.
getName
()));
return
result
;
}
}
logger-starter/secoo-log-starter/src/main/java/com/secoo/mall/logs/utils/HttpClientUtils.java
0 → 100644
View file @
cf68a533
This diff is collapsed.
Click to expand it.
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