Application Log Record Optimization via Code Injection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing application program log record generation methods consume significant hardware resources and reduce application program performance due to large log file storage and frequent IO operations, often resulting in loss of important information and requiring complex modifications to the program code.
Innovation Solution
The method involves identifying the original log method, separating character string parameters into constant and variable parts, establishing a correspondence flag, and constructing an optimized log method through code injection, which reduces storage size and IO operations by recording constant information once and variable information only when needed.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Loss of information
If the original log method records all log information to the log file, then the log information is complete and intact, but the storage size increases and IO operations become frequent
Solution Approach 1:
The patent segments the log information into two distinct parts: constant information (log template) and variable information (dynamic parameters). The constant part is extracted and stored separately in a memory buffer, while only the variable part is written to the log file during each logging operation. This segmentation reduces the amount of data written to disk while preserving complete log information integrity.
2Loss of information
If the original log method records all log information to the log file, then the log information is complete and intact, but the IO operations become frequent and performance decreases
Solution Approach 1:
By segmenting log information into constant and variable parts, the patent eliminates redundant writing of constant data to disk. The constant log template is loaded once into memory, and only variable parameters are appended during logging operations, significantly reducing IO frequency and improving application performance.
Solution Approach 2:
The patent performs preliminary action by pre-loading the constant log template into a memory buffer before actual logging operations occur. This preparation eliminates the need to repeatedly write the same constant information to disk, reducing IO operations and improving execution speed.
3Productivity
If the log file size is reduced by not recording constant information, then storage size and IO operations decrease, but the log information becomes incomplete
Solution Approach 1:
The patent introduces an intermediary mechanism - a memory buffer that stores the constant log template. This buffer acts as a mediator between the logging system and the log file, allowing constant information to be retained in memory while only variable information is persisted to disk. The complete log information is reconstructed by combining data from both the buffer and the log file.
4Quantity of substance
If the existing program code and log record mechanism are modified to reduce log file size, then storage efficiency improves, but the complexity of modification increases
Solution Approach 1:
The patent implements a self-service mechanism where the logging system automatically identifies, extracts, and separates constant and variable information from log statements without requiring manual code modification. The system autonomously builds the constant information buffer and handles the separation logic, eliminating the need for complex manual code changes while achieving log file size reduction.
Data Source
AI summary
The present invention relates to application program logs. In particular, the invention relates to a method and a system in which an original log method of an application program is optimized and newly injected to the application program. According to one aspect of the present invention, there is provided a method for optimizing an application program log record, comprising: identifying an original log method of an application program; separating a character string parameter in the original log method into a constant part and a variable part; establishing a correspondence flag between the constant part and the variable part; constituting an optimized log method by the constant part, the variable part and the correspondence flag; and replacing the original log method with the optimized log method through a code injection. With the above method, the hard disk storage amount of the log record and the IO operation frequency can be reduced.


