Python Logger

You can use NeptuneHandler to store logs from Python's Logger as a Runs metadata.

NeptuneHandler

A Handler object that sends the log records created by the logger to which it's attached to Neptune. Logs will be stored as a StringSeries field.

Parameters

run

(Run) - An existing run reference (as returned by neptune.init()).

level

(int, optional, default is logging.NOTSET) - Log level of the logs to be captured by the handler. Defaults to logging.NOTSET, which captures all logs that match logger's level.

path

(str, optional, default is None) - Path to the StringSeries field used for captured logs. If None, tracked metadata will be stored inside monitoring_namespace.

Examples

# Create a Python's Logger
import logging
logger = logging.getLogger("root_experiment")
logger.setLevel(logging.DEBUG)
# Create run
import neptune.new as neptune
run = neptune.init(project="WORKSPACE/PROJECT")
# Create a NeptuneHandler object to capture the logs
from neptune.new.integrations.python_logger import NeptuneHandler
npt_handler = NeptuneHandler(run=run)
logger.addHandler(npt_handler)
# Log something to the logger
logger.debug("Starting data preparation")
logger.debug("Data preparation done")