Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
9cbdd74b
Commit
9cbdd74b
authored
Oct 06, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
efaa4d0d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
5 deletions
+58
-5
AliyunLogProducer.java
...main/java/com/egolm/shop/aliyunLog/AliyunLogProducer.java
+15
-4
LogProducerConfig.java
src/main/java/com/egolm/shop/config/LogProducerConfig.java
+35
-0
application.properties
src/main/resources/application.properties
+8
-1
No files found.
src/main/java/com/egolm/shop/aliyunLog/AliyunLogProducer.java
View file @
9cbdd74b
...
...
@@ -7,6 +7,8 @@ import java.util.concurrent.Executors;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
com.aliyun.openservices.aliyun.log.producer.Producer
;
...
...
@@ -20,10 +22,19 @@ import com.google.common.util.concurrent.ListenableFuture;
@Component
public
class
AliyunLogProducer
{
@Autowired
private
Producer
producer
;
@Value
(
"${logProducer.project}"
)
private
String
project
;
@Value
(
"${logProducer.logStore}"
)
private
String
logStore
;
@Value
(
"${logProducer.isOpen}"
)
private
Boolean
isOpen
;
private
static
final
ExecutorService
EXECUTOR_SERVICE
=
Executors
.
newCachedThreadPool
();
private
static
final
Producer
producer
=
AliyunLogUtil
.
createProducer
();
private
static
final
String
project
=
System
.
getenv
(
"PROJECT"
);
private
static
final
String
logStore
=
System
.
getenv
(
"LOG_STORE"
);
public
void
sendLog
(
String
logText
)
{
try
{
...
...
src/main/java/com/egolm/shop/
aliyunLog/AliyunLogUtil
.java
→
src/main/java/com/egolm/shop/
config/LogProducerConfig
.java
View file @
9cbdd74b
package
com
.
egolm
.
shop
.
config
;
package
com
.
egolm
.
shop
.
aliyunLog
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.aliyun.openservices.aliyun.log.producer.LogProducer
;
import
com.aliyun.openservices.aliyun.log.producer.Producer
;
import
com.aliyun.openservices.aliyun.log.producer.ProducerConfig
;
import
com.aliyun.openservices.aliyun.log.producer.ProjectConfig
;
public
class
AliyunLogUtil
{
@Configuration
public
class
LogProducerConfig
{
public
static
Producer
createProducer
()
{
@Value
(
"${logProducer.project}"
)
private
String
project
;
@Value
(
"${logProducer.endpoint}"
)
private
String
endpoint
;
@Value
(
"${logProducer.accessKeyId}"
)
private
String
accessKeyId
;
@Value
(
"${logProducer.accessKeySecret}"
)
private
String
accessKeySecret
;
@Bean
public
Producer
createProducer
()
{
ProducerConfig
producerConfig
=
new
ProducerConfig
();
Producer
producer
=
new
LogProducer
(
producerConfig
);
producer
.
putProjectConfig
(
buildProjectConfig
(
));
producer
.
putProjectConfig
(
new
ProjectConfig
(
project
,
endpoint
,
accessKeyId
,
accessKeySecret
));
return
producer
;
}
private
static
ProjectConfig
buildProjectConfig
()
{
String
project
=
System
.
getenv
(
"PROJECT"
);
String
endpoint
=
System
.
getenv
(
"ENDPOINT"
);
String
accessKeyId
=
System
.
getenv
(
"ACCESS_KEY_ID"
);
String
accessKeySecret
=
System
.
getenv
(
"ACCESS_KEY_SECRET"
);
return
new
ProjectConfig
(
project
,
endpoint
,
accessKeyId
,
accessKeySecret
);
}
}
src/main/resources/application.properties
View file @
9cbdd74b
...
...
@@ -12,3 +12,10 @@ solr.goods.offset-minute-for-minute: 10
solr.goods.cron-for-day
:
0 0 3 * * ?
solr.goods.cron-for-minute
:
0 * * * * ?
solr.baseURL
=
http://10.10.0.15:8983/solr/goods
logProducer.isOpen
=
false
logProducer.project
=
linkfernlog
logProducer.logStore
=
linkfernlogstore
logProducer.endpoint
=
cn-shanghai.log.aliyuncs.com
logProducer.accessKeyId
=
LTAI4FvaitSjFD3X6gLeyyiR
logProducer.accessKeySecret
=
5zuFHabmMWzCHziPopQyoADqjKC4cv
\ 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