Giter VIP home page Giter VIP logo

aliyun-log-producer-sample's Introduction

Aliyun LOG Java Producer Sample Application

License

中文版 README

This repo provides the sample application for Aliyun LOG Java Producer, it will help you to master the producer library more quickly.

Prerequisite

You will need the following:

  • Opening Aliyun Log Service and create target project, logstore in advancce.
  • Prepare the AK used by producer.
  • Install JDK 1.6+.
  • Install Maven (brew install mavensudo apt-get install maven).

If you use the sub-account AK, you need to configure the following permissions for the account to ensure it can put logs to the target logstore.

Action Resource
log:PostLogStoreLogs acs:log:${regionName}:${projectOwnerAliUid}:project/${projectName}/logstore/${logstoreName}

Set environment variables

The sample will read the value of project, endpoint, logstore and AK from environment variables. You can set the value of them in .producerrc and then run the command source .producerrc.

Run the Sample

After the above tasks have been finished, do a clean build to compile the source code and generate jar:

mvn clean package

Then run the producer with callback to send some logs to your logstore:

mvn exec:java -Dexec.mainClass="com.aliyun.openservices.aliyun.log.producer.sample.SampleProducerWithCallback"

Run the producer with future to send some logs to your logstore:

mvn exec:java -Dexec.mainClass="com.aliyun.openservices.aliyun.log.producer.sample.SampleProducerWithFuture"

aliyun-log-producer-sample's People

Contributors

brucewu-fly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aliyun-log-producer-sample's Issues

producer.close();的调用时机

您好,按照您的sample集成到了项目里,但是发现第一次调用接口后执行到producer.close();第二次请求接口会报错,原因就是因为producer已经关闭了,现在我将close方法注释掉了,但是有个疑问,它的调用时机是什么时候?我尝试过这样做:

@PreDestroy
    public void exit() {
        // 关闭后台 io 线程,close 会将调用时刻内存中缓存的数据发送出去
        logProducer.close();
    }

也尝试过shutdownHook但每次关闭的时候都会抛异常,原因是producer是单例,关闭的时候这个对象已经被销毁了,现在有些手足无措,麻烦提供一个最佳实践或者指导一下整体日志服务的周期该怎么做。谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.