Aras Developer
Development

A Server-side Logging Guide for Aras Developers

Nithish Pandian
#logging#Aras Innovator#Serilog
Server-side Logging in Aras Innovator

Introduction to Server-side Logging in Aras Innovator

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.

Why the Change?

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.

Transitioning to Serilog-based Logging

To adopt the new logging system, developers need to configure logging settings and replace CCO.Utilities.WriteDebug() with the new CCO.Logger.Log() method.

Configuring Logging in appsettings.json

The 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.

Using the New CCO.Logger.Log() Method

Replace 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.

Understanding Log Levels

Serilog supports multiple log levels, each serving a specific purpose:

  • Debug: Detailed information for debugging purposes.
  • Information: General application flow information.
  • Warning: Indicates potential issues.
  • Error: Highlights errors that need attention.
  • Fatal: Critical errors that may lead to application failure.

Conclusion

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!