Logging with the settings in Logging.json

The PowerServer solution > UserExtensions project > Logging > Logging.json or Logging.Development.json file contains 1) the log level of PowerServer; 2) the logs to display in the console window; 3) the logging of SQLs, sessions, and transactions.

Settings in Logging.json file will take effect in the production environment (for example, when Web APIs is published and running in IIS, docker etc.). The default log level is warning.

Settings in Logging.Development.json file will take effect in the development environment (for example, when Web APIs is running from the SnapDevelop IDE or the PowerBuilder IDE). The default log level is warning.

The event levels include Trace, Debug, Information, Warning, Error, Critical, and None. The level change can be made at runtime (no need to restart the server).

To debug an error, you should set the log level to "Debug" or "Trace", in order to get as detailed error information as possible.

If you do not want to output the detailed logs, you can change the log level to "Error" or "Critical" (to output only error messages, no error context information).

The following is a sample log:

2021-03-05 09:09:09,080 ERROR PowerServerApi.ServerApiController.LogMessage [0] - MESSAGE: RequestId: CE1A2E41-0C93-4ff9-80FB-F98B096D4176, 
ErrorMessage: The INSERT statement conflicted with the CHECK constraint "check_age". The conflict occurred in database "Qa_datawindow", table 
"dbo.t_update_forcheck", column 'age'.
The statement has been terminated.