C3 AI Documentation Home

Log Messages for Troubleshooting

When implementing logic, it's a best practice to log information. This allows you to debug and troubleshoot your logic, both while developing the application, and later, when the application is running in production.

How to log information in JavaScript

To log information with the JavaScript SDK, start by initializing the logger, and then use it as part of your application logic:

JavaScript
function reticulateSplines(values) {
  var log = Logger.for('MyType.reticulateSplines');
  
  ...
  log.info("Computing spline values. Current value: {}", JSON.stringify(value));
  ...
}

Notice how you can use string interpolation to log specific objects.

The following log levels are available:

LevelDescription
ERRORIndicate there is an error that prevents functionality from being used.
WARNIndicate something unexpected happened in the application.
INFOIndicate a relevant event happened in the application.
DEBUGLog information that is useful when debugging or troubleshooting.
TRACELog very fine-grain information for when debug level is not enough.

How to log information in Python

To log information with the Python SDK, use the C3 AI Logger Type and create logger instance:

Python
# construct logger
logger = c3.Logger.for_(name="examplePackage.exampleType.py")

def reticulateSplines():
    logger.error(f'Computing spline values. Current value {value}')
    # Execute more logic

As the Python SDK uses the Logger Type, you can use all the functionality available in it, including different log levels, and string formatting.

See also

Was this page helpful?