HTTP SDK 사용 방법
- 인쇄
- PDF
HTTP SDK 사용 방법
- 인쇄
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Classic/VPC 환경에서 이용 가능합니다.
개요
HTTPS 프로토콜을 사용해서 Effective Log Search & Analytics에 로그를 전송할수 있으며, 아래와 같은 JSON 형식을 사용합니다.
{
"projectName": "72356c50401b8e20_testproject",
"projectVersion": "1.0.0",
"body": "This log message come from HTTPS client.",
"logLevel": "DEBUG",
"logType": "WEB",
"logSource": "https"
}
파라미터
파라미터 | 타입 | 필수 | 설명 |
---|---|---|---|
projectName | string | required | 프로젝트 아이디. 프로젝트 아이디를 확인하는 방법은 프로젝트 조회하기를 참고합니다. |
projectVersion | string | required | 프로젝트 버전. 기본값은 1.0.0이며, A~Z, a~z, 0~9, 하이픈(-), 온점(.), 밑줄(_)만을 포함할 수 있습니다. |
body | string | required | 로그 메시지. UTF-8을 사용하며 공백을 허용하지 않습니다. |
logSource | string | optional | 로그를 식별하기 위해 사용하며, 전송하지 않으면 기본값은 "json"입니다. |
logType | string | optional | 로그를 식별하기 위해 사용하며, 전송하지 않으면 기본값은 "nelo2-log"입니다. |
주의
JSON/HTTPS로 Effective Log Search & Analytics에 로그 전송 시 다음 주소를 사용해야 합니다.
https://elsa-col.ncloud.com/_store
"logTime"
와 "sendTime"
는 Effective Log Search & Analytics의 시스템에서 사용합니다. 두 가지 키를 사용 시 Effective Log Search & Analytics에서 무시합니다.
HTTPS 로그 전송은 PUT과 POST 방식만을 지원합니다.
로그 전송 예
curl을 사용하여 정상적으로 로그를 전송한 경우
POST 메서드를 사용하여 로그 전송
$ curl -XPOST 'https://elsa-col.ncloud.com/_store' -d '{
"projectName": "%YOUR_PROJECT_ID%",
"projectVersion": "1.0.0",
"body": "this log message come from https client, and it is a simple sample.",
"logLevel": "DEBUG",
"logType": "WEB",
"logSource": "https"
}'
PUT 메서드를 사용하여 로그 전송
$ curl -XPUT 'https://elsa-col.ncloud.com/_store' -d '{
"projectName": "%YOUR_PROJECT_ID%",
"projectVersion": "1.0.0",
"body": "this log message come from https client, and it is a simple sample.",
"logLevel": "DEBUG",
"logType": "WEB",
"logSource": "https"
}'
로그 전송이 실패하는 경우
URL이 잘못된 경우(_storess -> _store)
$ curl -XPOST 'https://elsa-col.ncloud.com/_storess' -d '{
"projectName": "%YOUR_PROJECT_ID%",
"projectVersion": "1.0.0",
"body": "this log message come from https client, and it is a simple sample.",
"_xxx": "this is a invalid key"
}'
잘못된 필드 키를 사용한 경우(_xxx)
$ curl -XPOST 'https://elsa-col.ncloud.com/_store' -d '{
"projectName": "%YOUR_PROJECT_ID%",
"projectVersion": "1.0.0",
"body": "this log message come from https client, and it is a simple sample.",
"_xxx": "this is a invalid key"
}'
이 문서가 도움이 되었습니까?