Skip to main content
App version: 3.4.10

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.

note

If you already use a logger, implement the NeptuneLoggingHandler to ensure that your logs are sent to Neptune.

Change the logging level

To control the severity of messages logged into stderr, use the NEPTUNE_LOGGER_LEVEL environment variable.

Change the storage location

By default, console logs are stored under the paths system/stdout and system/stderr.

To change the default system namespace, pass a different name to the system_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:

  1. Create a logger:

    import logging


    logger = logging.getLogger("my_experiment")
  2. Create a NeptuneLoggingHandler object 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)
  3. Capture logs:

    logger.debug("Starting data preparation")
    logger.debug("Data preparation done")

    By default, the records created by the logger are stored under the system/logs path. To change it, use the atribute_path parameter.

  4. To change the severity of logged messages, use the level parameter:

    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.