The Oracle Cloud Infrastructure (OCI) Logging service is a highly scalable and fully managed single pane of glass for all the logs in your tenancy. Logging provides access to logs from OCI resources, such as jobs and model deployments

ADS provides the APIs to simplify the creation, retrieval, and deletion of log groups and custom log resources.

Creating a log group requires a display name and compartment OCID. The compartment OCID is not needed if you are running the code in a Data Science notebook session.

from ads.common.oci_logging import OCILogGroup

# Create a new log group
# compartment_id is optional if running in a Data Science notebook session.
log_group = OCILogGroup(

# Get the log group OCID
log_group_ocid = log_group.id

# Create a custom log in the log group
log = log_group.create_log(display_name="<your_log_name>")

# Get the log OCID
log_ocid = log.id

# Delete a single log resource

# Delete the log group and the log resource in the log group

# Get a existing log group by OCID
log_group = OCILogGroup.from_ocid("<log_group_ocid>")

# Get a list of existing log resources in a log group
# A list of ads.common.oci_logging.OCILog objects will be returned

# Get the last 50 log messages as a list

# Stream the log messages to terminal or screen
# This block sthe main process until user interruption.