Debugging - Dynamic Log Controll
Overview
TeaQL provides a flexible system for managing logging configurations dynamically. Users can interact with the system using simple REST endpoints via curl commands to adjust log settings such as enabling or disabling markers, adding or removing denied URLs, and enabling or disabling user markers. Additionally, TeaQL provides programmatic methods for fine-grained control over logging behavior using Java.
This guide outlines how to use curl for configuring dynamic logs and also explains how to control log configurations programmatically.
After logging enabled by
curl http://localhost:port/logConfig/enableGlobalMarker/SQL_SELECT/
2025-12-27 11:19:53,209
[T2004754077140779008]
Alice-Microsoft-DEBUG-SQLLogger:112-
[4*EmployeePermission]
SELECT * FROM (SELECT id, permission_type AS "permissionType", authrity_level AS "authrityLevel", employee, version, (row_number() over(partition by employee ORDER BY id ASC)) as _rank from employee_permission_data WHERE (version > 0) AND (employee = 16)) as t where t._rank >= 1 and t._rank < 1001
The log shows the info
Trace ID:
T2004754077140779008
User:
Alice@Microsft
SQL statement:
'SELECT * FROM (
SELECT id, permission_type AS "permissionType", authrity_level AS "authrityLevel",
employee, version, (row_number() over(partition by employee ORDER BY id ASC))
as _rank
from
employee_permission_data WHERE (version > 0) AND (employee = 16)
) as t where t._rank >= 1 and t._rank < 1001'
returns:
4*EmployeePermission, 4 EmployeePermission object
- SQL can be copy-and-pasted to sql tools to verify the result
- SQL statements are executed with prepared statement and parameters, NO SQL INJECTION.
- enableGlobalMarker will affect all users
Key Concepts
TeaQL uses markers to categorize and track different types of log entries. You can control the logging configuration dynamically using the following features:
- Global Markers: For system-wide log tracking.
- User Markers: For tracking activities related to specific users.
- Denied URLs: Prevents certain URLs from being logged.
Common Log Markers
TeaQL defines a set of markers that can be enabled or disabled:
- SEARCH_REQUEST_START: Marks the start of a search request.
- SEARCH_REQUEST_END: Marks the end of a search request.
- SQL_SELECT: Tracks SQL select operations.
- SQL_UPDATE: Tracks SQL update operations.
- HTTP_REQUEST: Marks incoming HTTP requests.
- HTTP_RESPONSE: Marks outgoing HTTP responses.
These markers are key to controlling what data is logged and how it's categorized.
Using Curl for Dynamic Logging Configuration
TeaQL provides several REST endpoints that can be accessed via curl commands to manage the logging configuration. Below is a table of the available actions with example curl commands:
| Action | Endpoint | Description | Curl Example |
|---|---|---|---|
| Enable Global Marker | /logConfig/enableGlobalMarker/{markerName}/ | Enable a global marker for the entire system | curl -X GET http://<your-server>/logConfig/enableGlobalMarker/SQL_SELECT/ |
| Disable Global Marker | /logConfig/disableGlobalMarker/{markerName}/ | Disable a global marker | curl -X GET http://<your-server>/logConfig/disableGlobalMarker/SQL_SELECT/ |
| Add Denied URL | /logConfig/addDeniedUrl/{url}/ | Add a URL to the denied list | curl -X GET "http://<your-server>/logConfig/addDeniedUrl/http://example.com/" |
| Remove Denied URL | /logConfig/removeDeniedUrl/{url}/ | Remove a URL from the denied list | curl -X GET "http://<your-server>/logConfig/removeDeniedUrl/http://example.com/" |
| Enable User Marker | /logConfig/enableUserMarker/{markerNames}/ | Enable markers for specific users | curl -X GET http://<your-server>/logConfig/enableUserMarker/SQL_SELECT/ |
| Disable User Marker | /logConfig/disableUserMarker/{markerNames}/ | Disable markers for specific users | curl -X GET http://<your-server>/logConfig/disableUserMarker/SQL_SELECT/ |
| Enable All Logging | /logConfig/enableAll/ | Enable all markers globally | curl -X GET http://<your-server>/logConfig/enableAll/ |
| Reset Logging Configuration | /logConfig/reset/ | Reset the logging configuration to default settings | curl -X GET http://<your-server>/logConfig/reset/ |
How to Programmatically Control Logging Levels
In addition to using curl commands, TeaQL allows for programmatic control over the logging configuration using Java. This is useful when you need to make real-time adjustments based on the application context.
Example Code Snippet
In some cases, you might want to programmatically enable or disable log markers from within your application. Here's an example of how you can control the logging configuration programmatically:
ctx.getBean(LogConfiguration.class).enableGlobalMarker(markerName);
ctx.getBean(LogConfiguration.class).disableGlobalMarker(markerName);
ctx.getBean(LogConfiguration.class).addDeniedUrl(url);
ctx.getBean(LogConfiguration.class).removeDeniedUrl(url);
ctx.getBean(LogConfiguration.class).enableAll(ctx);
ctx.getBean(LogConfiguration.class).enableAll(ctx);
When to Use Programmatic Control
- Conditional Logging: When certain conditions in your application require dynamically enabling or disabling specific log markers (e.g., during a user session or a special event).
- Real-Time Adjustments: If you need to adjust the logging configuration based on the application state or external triggers, such as debugging or monitoring modes.
- Custom Logging for Users: For cases where you want to enable specific logging configurations based on user preferences or roles (e.g., tracking only certain types of activities for premium users).
Conclusion
TeaQL's dynamic logging configuration system offers a versatile way to manage log markers both through curl commands and programmatic control. The ability to enable or disable global and user-specific markers, along with adding or removing denied URLs, makes it easy to fine-tune your logging strategy. Whether you're managing logs from the command line with curl or adjusting them within your application code, TeaQL provides the flexibility to ensure that your logging system meets your needs.