huaweicloud-sdk-nodejs-v3 icon indicating copy to clipboard operation
huaweicloud-sdk-nodejs-v3 copied to clipboard

Provide way to disable file logging or change log filename

Open dtinth opened this issue 3 years ago • 1 comments

I am trying to use the SDK in FunctionGraph. However when I make an API call, it failed because Node.js cannot open file HuaweiCloud-SDK-Access.log for writing (EACCESS error).

image

Workaround

My current workaround is to chdir to a temporary directory, which is writable by FunctionGraph:

// At the top of index.js
process.chdir('/tmp')

// Then use as usual
const { BasicCredentials } = require('@huaweicloud/huaweicloud-sdk-core')
const { EcsClient } = require('@huaweicloud/huaweicloud-sdk-ecs')

dtinth avatar Nov 23 '21 19:11 dtinth

Sorry for the inconvenience. According to the information you provided, I was unable to reproduce the problem you were experiencing.

I retried the issue you raised, and when specifying a temporary directory, log files are generated in the temporary directory.

Can you please confirm if the HuaweiCloud-SDK-Access.log has been generated successfully in the /tmp directory?

From the logs on the image, it seems that there is no permission to read the files in the temporary directory.

Can you provide more detailed steps?

Thank you!

akhuang avatar Dec 13 '21 07:12 akhuang

You can set the configuration of Log4j before calling the HuaweiCloud SDK, which will be executed with higher priority.

import * as log4js from "log4js";
log4js.configure({
  appenders: { cheese: { type: "file", filename: "cheese.log" } },
  categories: { default: { appenders: ["cheese"], level: "error" } },
});

akhuang avatar Feb 27 '23 12:02 akhuang