Logging is a critical aspect of software development, providing insights into application behavior and aiding in debugging. With Aras Innovator Release 14, the traditional CCO.Utilities.WriteDebug() method has been deprecated in favor of a more robust logging system powered by Serilog. This guide will help you transition to the new logging system effectively.
The CCO.Utilities.WriteDebug() method served its purpose well in earlier versions of Aras Innovator. However, Aras Innovator Release 14 introduces a new logging system based on Serilog, offering enhanced flexibility, configurability, and advanced features such as structured logging and support for multiple log sinks.
To adopt the new logging system, developers need to configure logging settings and replace CCO.Utilities.WriteDebug() with the new CCO.Logger.Log() method.
appsettings.jsonThe logging configuration is managed in the appsettings.json file. Below is an example configuration:
"Logging": {
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"System": "Error"
}
},
"WriteTo": [
{ "Name": "Console" },
{ "Name": "File", "Args": { "path": "logs/log.txt" } }
]
}
}
This configuration sets the minimum log level to Debug and directs logs to both the console and a file.
CCO.Logger.Log() MethodReplace instances of CCO.Utilities.WriteDebug() with the new CCO.Logger.Log() method. Here’s an example:
CCO.Logger.Log(LogLevel.Debug, "Hello world!");
This method allows you to specify the log level (Debug, Information, Warning, etc.) and the log message.
Serilog supports multiple log levels, each serving a specific purpose:
Transitioning to the Serilog-based logging system in Aras Innovator Release 14 is a significant improvement that enhances logging flexibility and capabilities. By configuring logging settings in appsettings.json and using the CCO.Logger.Log() method, developers can leverage advanced logging features to streamline debugging and improve application monitoring.
Make the switch today and elevate your server-side logging experience!