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:
| Level | Description |
|---|---|
ERROR | Indicate there is an error that prevents functionality from being used. |
WARN | Indicate something unexpected happened in the application. |
INFO | Indicate a relevant event happened in the application. |
DEBUG | Log information that is useful when debugging or troubleshooting. |
TRACE | Log 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 logicAs the Python SDK uses the Logger Type, you can use all the functionality available in it, including different log levels, and string formatting.