huaweicloud-sdk-nodejs-v3
huaweicloud-sdk-nodejs-v3 copied to clipboard
Provide way to disable file logging or change log filename
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).
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')
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!
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" } },
});