Application log
Introduction to the Application log
The application log is a solution you can download from the Thinkstore.
It keeps track of all the tasks, subroutines (stored_procedures
), handlers and triggers within your Thinkwise application.
This is useful for debugging and auditing purposes.
Architecture
The application log uses sequences to generate unique log numbers for each procedure call. A system flow runs at 01:00 every night by default to delete all the logs older than 90 days at the time of running. You can adjust both the time and the number of days.
The application log displays all sessions in a tree view, providing an overview of which procedure initiated the sequence and how procedures are nested or invoked by others. Two screen types are available to show the logs, which include a breakpoint to optimize the view for smaller screens. You can find further information on the session in the detail of the tree view.
Example of the application log tree view
The example below demonstrates that the update handler of the employee initiated the sequence.
It executed the task task_one
, which initiated task_two
.
Task_two
then inserted a record in date_conversion
, which has an instead-of
trigger.
After completion of task_one
, the handler then updated the employee record, which has a trigger employee_tu
.
Example of the application log tree view
Detail of the application log
Application log table
In the application log, the logs are stored in the application_log
table.
All the log dates are stored in Universal Time Coordinated (UTC) format.
Do not add trace columns or triggers to the application_log
table, as this can cause performance issues.
It can also lead to a deadlock situation where the application log is being written to and the trigger is trying to write to the same table.
The application_log
table contains the following columns:
Column | Datatype | |
---|---|---|
application_log_id | bigint | Identity, PK |
session_log_number | bigint | The log number of the first procedure that started the sequence of procedures. |
parent_log_number | bigint | The log number of the procedure that started this procedure. |
log_number | bigint | The log number of the procedure itself. |
log_nestlevel | int | The nest level of the procedure. |
type_of_log | char(1) | s – start of the procedure d – debug row (added manually) f – procedure is finished. |
object_name | varchar(256) | The name of the procedure coming from the SQL server. |
procedure_parameters | nvarchar(max) | The parameters of the procedure, they could be different at the start and finish. |
contains_transaction | bit | Indicates if the current procedure contains a transaction. |
log_severity | char(1) | i – information w – warning e – error f – fatal |
log_info | nvarchar(max) | In case of a catch this will be filled with a JSON containing the error. For manual log lines, it is flexible. |
log_user | varchar(128) | The user that initiated the procedure. |
log_date_time | datetime2 | Date and time of the log line. |
Parameters and columns with large amounts of data
By default, all the parameters and columns are logged in procedure_parameters
,
except for parameters and columns with potentially large amounts of data (such as varchar(max)
and varbinary
).
To include these parameters in the log, attach the tag include_in_application_log
to the parameter or column.
Custom values
To log custom values, you can either add the log line manually by creating an insert statement in the application_log
table or use the provided subroutine application_log_add
.
exec dbo.application_log_add @tsf_log_number, @tsf_object_name, 'Log info'
Exclude a procedure
To exclude a procedure from the application log, use the extended property exclude_from_application_log
.
Performance
The value for for the sequence Cache is set to 250 by default. If your application frequently requests new sequence values, you can increase this value to improve performance. For more information, see Sequences and the Microsoft documentation.