Console logs
Capture console logs, send them to Neptune and analyze them in the app.
Capture console logs
Neptune logs the standard streams stderr and stdout automatically.
Logs are stored in a run as a StringSeries attribute.
If you already use a logger, implement the NeptuneLoggingHandler to ensure that your logs are sent to Neptune.
Change the storage location
By default, console logs are stored under the paths runtime/stdout and runtime/stderr.
To change the default runtime namespace, pass a different name to the runtime_namespace argument.
Disable tracking
To disable the tracking of console logs, set the enable_console_log_capture parameter to False.
Log Python Logger output
To capture logs with the Python Logger, use the NeptuneLoggingHandler object. It gives you more control over the type of information that you log to Neptune.
To log the Logger output to Neptune:
-
Create a logger:
import logging
logger = logging.getLogger("my_experiment") -
Create a
NeptuneLoggingHandlerobject and add it to the logger:from neptune_scale import Run
from neptune_scale import NeptuneLoggingHandler
run = Run(
api_token="eyJhcGlfYWRkcmVz...In0=",
project="team-alpha/project-x",
)
npt_handler = NeptuneLoggingHandler(run=run)
logger.addHandler(npt_handler) -
Capture logs:
logger.debug("Starting data preparation")
logger.debug("Data preparation done")By default, the records created by the logger are stored under the
runtime/logspath. To change it, use theattribute_pathparameter. -
To change the severity of logged messages, use the
levelparameter:npt_handler = NeptuneLoggingHandler(run=run, level=3)
View logs in the Neptune app
To view the logged messages in the Neptune app, navigate to the Attributes tab of a selected run.
You can also configure a logs widget to display the captured logs in your dashboards and reports.