Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.76 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.76 KB

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"