Ganache-cli: How to listen to existing Ganache instance in another Terminal tab or window?

Created on 7 Nov 2020  路  4Comments  路  Source: trufflesuite/ganache-cli

Let's say I run ganache-cli in a terminal tab. Is it possible to listen to the same Ganache instance in another terminal tab or window (and see all the logs)? If yes, how?

Most helpful comment

Ah, you just need to add logger: console, to your ganache.server options, like this:

const server = ganache.server({
  logger: console,
  port: PORT,
  fork: process.env.MAINNET_NODE_URL,
  network_id: 1,
  accounts: [
    {
      secretKey: process.env.PRIV_KEY_TEST,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
    {
      secretKey: process.env.PRIV_KEY_DEPLOY,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
  ],
});

All 4 comments

Might be possible on some platforms. Examples can be found on https://askubuntu.com/questions/703516/execute-command-in-one-terminal-and-get-the-output-in-another-terminal-it-it-pos

What is your use case here?

Hi @davidmurdoch , my usecase is that I start Ganache with JavaScript code (like this), but then I don't see transaction logs in the Terminal whenever I make an ETH transaction.

Ah, you just need to add logger: console, to your ganache.server options, like this:

const server = ganache.server({
  logger: console,
  port: PORT,
  fork: process.env.MAINNET_NODE_URL,
  network_id: 1,
  accounts: [
    {
      secretKey: process.env.PRIV_KEY_TEST,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
    {
      secretKey: process.env.PRIV_KEY_DEPLOY,
      balance: ethers.utils.hexlify(ethers.utils.parseEther("1000")),
    },
  ],
});

Nice! Thank you very much David! 馃檪

Was this page helpful?
0 / 5 - 0 ratings