Normally our application logging with a standard format to console in docker environment, the logging is directly capture from console output. I am facing an issue that the smart contract having multiple functions with a same name, the ethers will output a warning message to console.
WARNING: Multiple definitions for XXXX
Do you have any idea to disable the console.log inside ethers library?
I probably should add something to the errors to disable warnings. There isn鈥檛 anything easy to do until I update that though. Do you need function overloading? That itself can lead to bugs... :s
As I think about this more, I think future versions won鈥檛 allow ambiguous calls. If there is a transfer(uint) and transfer(address) then both explicit functions will be available, but calling transfer will throw an ambiguous call exception.
I鈥檒l experiment with this in the v5 branch tomorrow.
For v4, I鈥檒l just add an errors.disableWarnings = true option.
You should now be able to set the internal log level:
ethers.errors.setLogLevel("debug");
ethers.errors.setLogLevel("default");
ethers.errors.setLogLevel("info");
ethers.errors.setLogLevel("warn");
ethers.errors.setLogLevel("error");
ethers.errors.setLogLevel("off");
Let me know if that works for you.
Thanks! :)
Closing this now, but I monitor closed issues. Let me know if there are any issues, or feel free to re-open. :)
Thanks! :)
How do I disable log in v5 ?
I'd like to get rid of these duplicate definition message in the log
Ah yes, I noticed a few weeks ago I have not added that yet. I will add it today.
Any update on this ?
Ah yes, I just added this the other day, but haven鈥檛 published the change yet.
I鈥檒l do that today with a few other changes that need to be published.
By the way, this should be available in the latest published version. :)
Useing "ethers": "^5.0.0-beta.175",
Getting this while trying to turn of this logs:

I think you need ethers.utils.Logger.setLogLevel instead. Let me know if that doesn鈥檛 solve it...
With "ethers": "^5.0.0-beta.175",
and
const ethers = require('ethers');
ethers.utils.Logger.setLogLevel('off');
I get the following error :
TypeError: ethers.utils.Logger.setLogLevel is not a function
Was it added in beta.175 ?
There was a bug that prevented warnings from being properly suppressed. Please try out 5.0.0-beta.177 and use the ethers.utils.Logger.setLogLevel("off") to try it out.
Let me know if there are any problems. :)
I still get the issue
TypeError: ethers.utils.Logger.setLogLevel is not a function in some project where the dependency on ethers is "ethers": "^5.0.0-beta.181",
I guess it is related to how other project depend on other ethers packages
I noticed the various packages have a dependency on "@ethersproject/logger": ">=5.0.0-beta.129",
it should be "@ethersproject/logger": ">=5.0.0-beta.136", no ?
I workaround it by adding
"resolutions": {
"@ethersproject/logger": "5.0.0-beta.136"
}
I'm using 5.0.7 in my ts rollup build:
src/index.ts:9:33 - error TS2345: Argument of type '"off"' is not assignable to parameter of type 'LogLevel'.
9 ethers.utils.Logger.setLogLevel('off'); // turn off warnings
Found 1 error.
Shouldn't this work? Is there an export of LogLevel on the ethers class? Thank you.
@ajb413
It鈥檚 an enum, so can you try Logger.levels.OFF instead of the string "off"? Let me know if that still doesn鈥檛 work.
whoops wrong browser tab, meant to post in https://github.com/ethers-io/ethers.js/issues/947
anyway:
ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR); // turn off warnings
is the cure, I only want to turn off warnings because an ABI has an overloaded event that was triggering the warning. Thank you @ricmoo !!
Most helpful comment
You should now be able to set the internal log level:
Let me know if that works for you.
Thanks! :)