Separating xray logs from nodejs application logs in cloudwatch

0

Hi, I have enabled xray in our nodejs application. but we are receiving exponentials logs from xray service in our logs in cloudwatch, which is making us difficult to check logs for custom functionality. Is there any way to specify a separate log group for xray?

질문됨 일 년 전337회 조회
1개 답변
1
수락된 답변

Hello,

I understand that you would like to know if you can configure a separate log group for X-ray SDK for Node.js.

You can configure the X-Ray SDK for Node.js with plugins to include information about the service that your application runs on, modify the default sampling behavior, or add sampling rules that apply to requests to specific paths.

If you wish to provide a different format or destination for the logs then you can provide the SDK with your own implementation of the logger interface as shown below. Any object that implements this interface can be used. This means that many logging libraries, e.g. Winston, could be used and passed to the SDK directly. Below is an example:

Example app.js - logging:

-----------------------------
var AWSXRay = require('aws-xray-sdk');

// Create your own logger, or instantiate one using a library.
var logger = {
  error: (message, meta) => { /* logging code */ },
  warn: (message, meta) => { /* logging code */ },
  info: (message, meta) => { /* logging code */ },
  debug: (message, meta) => { /* logging code */ }
}

AWSXRay.setLogger(logger);
AWSXRay.config([AWSXRay.plugins.EC2Plugin]);

-----------------------------

Call setLogger before you run other configuration methods to ensure that you capture output from those operations.

Hope this answers your query!

Regards

References: [+]https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-configuration.html#xray-sdk-nodejs-configuration-envvars

[+]https://docs.aws.amazon.com/xray-sdk-for-nodejs/latest/reference/

AWS
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인