Settings and Logging

neo-python has a settings module which you can use to configure several things:

  • The network: MainNet, TestNet, private networks or custom configs
  • Logging:
    • Smart contract event logging
    • Logfile (optionally rotating)
    • Loglevel

To change settings, you have to import the settings instance like this:

from neo.Settings import settings

Setting the network

You can use the following settings methods to configure the network:


By default, neo-python uses the TestNet.

Where to save data:

By default, neo-python saves chain data at ~/.neopython/Chains. If you would like to change this, you can pass the --datadir flag to any of the commands (np-prompt, np-api-server,``np-bootstrap``) to specify where the Chains directory should be placed. You can also set this manually via the settings module like so:



neo-python uses the following defaults:

  • all events from all smart contracts are logged with loglevel INFO
  • loglevel is set to INFO
  • logging to a logfile is deactivated ( logs to prompt.log)

Smart Contract Events

If you want to disable logging of all smart contract events, you can do so:


Changing the loglevel

To change the loglevel (eg. to also show DEBUG logs, or to only show ERRORS):

import logging

# Show everything, including debug logs:

# Only show errors:

Changing in the prompt

To change the loglevel in the prompt interface, use the following command

neo> config sc-events on
neo> config sc-events off

Configuring a logfile

To enable logging to a logfile:

# Just a single logfile, with no limits or rotation:

# To enable rotation with a maximum of 10MB per file and 3 rotations:
settings.set_logfile(your_logfile_path, 1e7, 3)

Logging in custom code

neo-python is using logzero for logging. To use a logger with the existing neo logging configuration, you can just import the logger from logzero:

from logzero import logger

# These log messages are sent to the console

# This is how you'd log an exception
    raise Exception("this is a demo exception")
except Exception as e: