Commit 9cbdd74b authored by Quxl's avatar Quxl

x

parent efaa4d0d
...@@ -7,6 +7,8 @@ import java.util.concurrent.Executors; ...@@ -7,6 +7,8 @@ import java.util.concurrent.Executors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aliyun.openservices.aliyun.log.producer.Producer; import com.aliyun.openservices.aliyun.log.producer.Producer;
...@@ -19,12 +21,21 @@ import com.google.common.util.concurrent.ListenableFuture; ...@@ -19,12 +21,21 @@ import com.google.common.util.concurrent.ListenableFuture;
@Component @Component
public class AliyunLogProducer { 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 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) { public void sendLog(String logText) {
try { try {
List<LogItem> logItems = new ArrayList<LogItem>(); List<LogItem> logItems = new ArrayList<LogItem>();
......
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.LogProducer;
import com.aliyun.openservices.aliyun.log.producer.Producer; import com.aliyun.openservices.aliyun.log.producer.Producer;
import com.aliyun.openservices.aliyun.log.producer.ProducerConfig; import com.aliyun.openservices.aliyun.log.producer.ProducerConfig;
import com.aliyun.openservices.aliyun.log.producer.ProjectConfig; import com.aliyun.openservices.aliyun.log.producer.ProjectConfig;
public class AliyunLogUtil { @Configuration
public class LogProducerConfig {
@Value("${logProducer.project}")
private String project;
@Value("${logProducer.endpoint}")
private String endpoint;
@Value("${logProducer.accessKeyId}")
private String accessKeyId;
@Value("${logProducer.accessKeySecret}")
private String accessKeySecret;
public static Producer createProducer() { @Bean
public Producer createProducer() {
ProducerConfig producerConfig = new ProducerConfig(); ProducerConfig producerConfig = new ProducerConfig();
Producer producer = new LogProducer(producerConfig); Producer producer = new LogProducer(producerConfig);
producer.putProjectConfig(buildProjectConfig()); producer.putProjectConfig(new ProjectConfig(project, endpoint, accessKeyId, accessKeySecret));
return producer; 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);
}
} }
...@@ -11,4 +11,11 @@ solr.goods.offset-minute-for-day: 1500 ...@@ -11,4 +11,11 @@ solr.goods.offset-minute-for-day: 1500
solr.goods.offset-minute-for-minute: 10 solr.goods.offset-minute-for-minute: 10
solr.goods.cron-for-day: 0 0 3 * * ? solr.goods.cron-for-day: 0 0 3 * * ?
solr.goods.cron-for-minute: 0 * * * * ? solr.goods.cron-for-minute: 0 * * * * ?
solr.baseURL=http://10.10.0.15:8983/solr/goods solr.baseURL=http://10.10.0.15:8983/solr/goods
\ No newline at end of file
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment