Logging
The logging feature allows for writing to the jetveo logs. This applies to the current instance. On a preview instance, the logs are written to the underlying developer instance, with a message prefix specifying it is from the preview instance.
Use the App.Log
object, and call one of the following methods, based on the desired log level. This is possible in Custom Code and Business Commands.
The methods Debug
, Info
, Warning
each take in a string argument for the title, and an object
that is deserialized as JSON into the full log message. Any object can be passed successfully to these methods.
App.Log.Debug("message", object);
App.Log.Info("message", object);
App.Log.Warning("message", object);
The method Error
also takes in a string argument, but instead of any object, it takes in an Exception
as the message.
App.Log.Error("message", exception);
int[] array = { 0 };
try
{
int x = array[100];
}
catch (Exception e)
{
App.Log.Error("Invalid memory access", e);
}
executing this code logs the following error:
Custom message objects
For logging multiple values at once, such as displaying variables from code or displaying arguments
in a function call, you do not need to make a custom class or record. You can simply use new
followed
by an object initializer. This allows for nested objects, but for clarity in the logs, it limits the
nesting level to one.
public static RecordList<T>? GetRecordList<T>(HttpClient client, int limit, int offset)
{
App.Log.Debug($"Entering Recordlist<{typeof(T)}>", new {
client = client,
limit = limit,
offset = offset
});
...
Debug logs
The debug logs include:
- Every message logged as
Debug
- Every command call, which consists of:
- Command ID and Name
- Success (true or false)
- Execution Time How long the command took to execute. (in milliseconds)
- Queue Time How long the command waited in the queue before starting execution (in milliseconds)
- Every API call (This feature can be enabled or disabled).
Info logs
The info logs include:
- Every message logged as
Info
- Application starting and stopping
Configuring the application logs
You can specify the minimum log level that the application instance produces. It is often useful to log all debug information during testing, but in a production environment, this might produce unnecessarily large data.
The log levels are ordered by severity: Debug
, Info
, Warning
, and Error
.
To configure the logs, navigate to the settings
of the application instance. On the General
page, you will find the following options:
Minimum log level
Specifies the minimum log level, that will be logged on the JetVeo platform, and written to the standard output by the running app.Minimum log level for file logs
Specifies the minimum log level, that the application logs into a file locally. The log files are available in thelogs
directory, that is created in the directory from which the app is run. (Not available on cloud instances).Log API Calls
This enables logs about every api call, that will be logged asDebug