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

1
# Create a Python's Logger
2
import logging
3
logger = logging.getLogger("root_experiment")
4
logger.setLevel(logging.DEBUG)
5
6
# Create run
7
import neptune.new as neptune
8
run = neptune.init(project="WORKSPACE/PROJECT")
9
10
# Create a NeptuneHandler object to capture the logs
11
from neptune.new.integrations.python_logger import NeptuneHandler
12
npt_handler = NeptuneHandler(run=run)
13
logger.addHandler(npt_handler)
14
15
# Log something to the logger
16
logger.debug("Starting data preparation")
17
logger.debug("Data preparation done")
Copied!
Export as PDF
Copy link