WO2020238049A1 - Attribute configuration method and apparatus for log4j log framework, and computer device - Google Patents

Attribute configuration method and apparatus for log4j log framework, and computer device Download PDF

Info

Publication number
WO2020238049A1
WO2020238049A1 PCT/CN2019/117667 CN2019117667W WO2020238049A1 WO 2020238049 A1 WO2020238049 A1 WO 2020238049A1 CN 2019117667 W CN2019117667 W CN 2019117667W WO 2020238049 A1 WO2020238049 A1 WO 2020238049A1
Authority
WO
WIPO (PCT)
Prior art keywords
system variable
designated
attribute
specified
attribute value
Prior art date
Application number
PCT/CN2019/117667
Other languages
French (fr)
Chinese (zh)
Inventor
陈林
丁磊磊
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020238049A1 publication Critical patent/WO2020238049A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Definitions

  • This application relates to the computer field, and in particular to a method, device, computer equipment, and storage medium for configuring log4j log framework attributes.
  • log records are often used. For example, online problem tracking, log-based business logic statistical analysis, etc. are inseparable from logs.
  • log frameworks among which log4j log framework is a commonly used one.
  • attribute configuration for example, attribute modification
  • the server needs to be restarted, making attribute configuration (for example, attribute modification) time-consuming and unable to take effect quickly. Therefore, the prior art lacks a solution that can perform real-time attribute configuration on the log4j log framework and solve the technical problem that attribute configuration takes a long time and cannot take effect quickly.
  • the main purpose of this application is to provide a log4j log framework attribute configuration method, device, computer equipment and storage medium, aiming to solve the technical problem that attribute configuration takes a long time and cannot take effect quickly.
  • this application proposes a method for configuring the attributes of the log4j log framework, which includes the following steps:
  • a preset configuration file is retrieved, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to the designated system variable Special symbol
  • This application provides an attribute configuration device of log4j log framework, including:
  • the attribute configuration instruction receiving unit is configured to receive an attribute configuration instruction to the log4j log framework, and the attribute configuration instruction carries a specified attribute value;
  • the configuration file retrieval unit is configured to retrieve a preset configuration file according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable accounts for Bit symbol refers to the special symbol that represents the specified system variable;
  • the designated attribute value judgment unit is configured to obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
  • the attribute value editing unit is configured to, if the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
  • the update unit is configured to call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  • the present application provides a computer device including a memory and a processor, the memory stores computer readable instructions, and the processor implements the steps of any one of the above methods when the computer readable instructions are executed.
  • the present application provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of any of the above methods are implemented.
  • the attribute configuration method, device, computer equipment and storage medium of the log4j log framework of this application receive an attribute configuration instruction for the log4j log framework; call a preset configuration file, where the specified attribute in the configuration file is set at the position There is a designated system variable placeholder; the designated system variable is obtained by using the designated system variable placeholder; if the designated system variable is different from the designated attribute value, the designated system variable is edited as the Specify the attribute value; call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file.
  • real-time attribute configuration of the log4j log framework is realized, and the technical problem that attribute configuration takes a long time and cannot take effect quickly is solved.
  • FIG. 1 is a schematic flowchart of an attribute configuration method of the log4j log framework according to an embodiment of the application
  • FIG. 2 is a schematic block diagram of the structure of a device for configuring an attribute of a log4j log framework according to an embodiment of the application;
  • FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
  • an embodiment of the present application provides a method for configuring attributes of the log4j log framework, including the following steps:
  • the attribute configuration instruction retrieve a preset configuration file, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to a designated system Special symbols for variables;
  • This application uses designated system variable placeholders, and when the attributes need to be modified, only the designated system variables can be edited accordingly, thereby overcoming the shortcomings of time-consuming and inability to quickly take effect caused by restarting the server.
  • an attribute configuration instruction to the log4j log framework is received, and the attribute configuration instruction carries a specified attribute value.
  • the attribute configuration instruction is used to instruct to configure the attributes of the log4j log framework, for example, to configure attributes such as log level and log file storage path, with the purpose of configuring the specified attribute to be the specified attribute value carried by the attribute configuration instruction.
  • a preset configuration file is called, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder Symbols refer to special symbols that represent specified system variables.
  • the configuration of properties requires the use of preset configuration files to obtain the property values to be configured.
  • a designated system variable placeholder is set at the position of the designated attribute in the configuration file, so that when the attribute needs to be modified, only the designated system variable can be edited accordingly, and the configuration file does not need to be modified.
  • placeholders are symbols that occupy a fixed position and wait for you to add content to them; and system variable placeholders are special symbols that represent system variables; system variables refer to the data storage location defined by the system. Recorded data.
  • system variable placeholders are not ordinary placeholders, because the system variable placeholders represent system variables, and the system variables can be edited without opening the configuration file, so that the configuration file is not modified. The modification of attributes therefore avoids the disadvantages of time-consuming and unable to take effect quickly due to the need to restart the server during attribute configuration (modification) in the traditional method.
  • the state of the system variable placeholder in the configuration file is, for example: all attribute positions in the configuration file are occupied by system variable placeholders; or, there is only designated The attribute position is occupied by a system variable placeholder; or, other attribute positions in the configuration file except the specified attribute position record the attribute value or are occupied by the system variable placeholder.
  • the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value.
  • the system variable placeholder is a special symbol representing the system variable. Therefore, the designated system variable can be obtained by querying the designated system variable placeholder. Then judge whether the specified system variable is the same as the specified attribute value; if the specified system variable is the same as the specified attribute value, that is, the current attribute value is the same as the specified attribute value, so no attribute update is required; If the system variable is different from the specified attribute value, an attribute update operation is required.
  • a preset system variable editing method is called to edit the designated system variable to the designated attribute value. If the specified system variable is different from the specified attribute value, an attribute update operation is required.
  • a method is also called a function, which is a collection of statements that perform a function together.
  • the system variable editing method is used to edit the system variable. Since the system variable editing method is preset, the system variable editing can be realized by directly calling this method.
  • the method for editing the system variable is, for example, obtaining the position of the system variable; deleting the system variable data; recording the pre-prepared variable data into the system variable position, so as to realize the editing of the system variable.
  • step S5 call the preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework .
  • the configuration file loading method is used to load a configuration file to update all or part of the attributes. Therefore, by calling the preset configuration file loading method, the attribute update operation can be performed, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attributes of the log4j log framework Configuration.
  • the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies Place symbol refers to the special symbol representing the designated system variable before step S2, including:
  • the position of the tag attribute in the configuration file is set as a system variable placeholder. If some attributes of the log4j log framework are not frequently modified, then these attributes can be directly recorded in the configuration file with specific attribute values, and there is no need to use system variable placeholders. However, for attributes that have been modified more than the preset number threshold within a predetermined time, because they are often modified, system variable placeholders need to be used. Thus, the attributes in the configuration file are divided into specific attribute values or system variable placeholders according to the number of times they have been modified, thereby reducing the increase in system burden caused by all use of system variable placeholders in the configuration file ( System variable placeholders take up more space) defects.
  • the step S3 of obtaining the designated system variable by using the designated system variable placeholder, and determining whether the designated system variable is the same as the designated attribute value includes:
  • S301 Acquire the designated system variable by using the designated system variable placeholder according to the preset correspondence between the system variable placeholder and the system variable;
  • S302 Calculate the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm
  • the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value.
  • the preset similarity algorithm is, for example, the WMD algorithm (word move's distance), the simhash algorithm, and the algorithm based on cosine similarity and word frequency vector similarity.
  • the foregoing algorithms are all mature algorithms and will not be repeated here. If the similarity value is less than the preset similarity threshold, it is determined that the specified system variable is not the same as the specified attribute value; if the similarity value is not less than the preset similarity threshold, it is determined that the specified The system variable is the same as the specified attribute value.
  • the purpose of this embodiment is to be compatible with the miswriting of the specified attribute value carried by the attribute configuration instruction. For example, if DEBUG is mistakenly written as DEBAG, the similarity algorithm according to this embodiment will determine that the two are the same, so there is no need to update the attribute. This avoids the use of ordinary text comparison methods (comparing characters one by one, if there is a difference, the judgment is not the same) to judge the two as different, which will lead to the subsequent incorrect unrecognizable DEBAG (DEBUG is the log level, and DEBAG is not) Set to the attribute value of the log4j log frame, causing serious errors.
  • the step S302 of calculating the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm includes:
  • the preset similarity algorithm is used to calculate the similarity value between the designated system variable and the designated attribute value.
  • the similarity algorithm is calculated according to the cosine similarity between the designated system variable and the designated attribute value, so as to reflect the degree of similarity between the designated system variable and the designated attribute value. When the value of similarity is closer to 1, the more similar is; the closer to 0, the less similar.
  • the step S4 of calling a preset system variable editing method to edit the designated system variable to the designated attribute value includes :
  • the user accounts in the preset list of authorized users have the authority to edit system variables, so as to reduce the possibility of system variables being tampered with.
  • the preset parameter range limits the parameter content that the specified system variable can be set.
  • the log level can be set to five levels: DEBUG, INFO, WARN, ERROR and FATAL, that is, the preset parameter range is DEBUG, INFO, WARN , ERROR and FATAL. Therefore, authorization verification and parameter verification are performed first to reduce the possibility of attribute configuration errors.
  • the reminder information of the parameter error is returned to the terminal that sends the attribute configuration instruction of the log4j log framework.
  • the specified attribute value exceeds the preset parameter range of the specified system variable, the specified attribute value cannot be configured, otherwise it will cause an error in the log4j log framework.
  • the preset parameter range of the log level is DEBUG, INFO, WARN , ERROR and FATAL, and the specified attribute value is right, which exceeds the preset parameter range of the specified system variable, a warning message of parameter error should be generated, and the warning message of the parameter error should be returned to the sender of the log4j log frame The terminal of the attribute configuration command.
  • the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file Updating the current attribute value to the designated attribute value to complete the step S5 of the attribute configuration of the log4j log framework includes:
  • the property configuration of the log4j log framework is completed.
  • other attributes in the configuration file other than the specified attribute record the preset attribute value, so there is no need to update the other attributes when performing attribute configuration (attribute update) (so the configuration file is not modified, so It is impossible to change other attributes), which reduces the amount of calculation and improves the speed of attribute configuration. Accordingly, only the designated attribute of the log4j log framework is updated to the designated attribute value, and the values of the other attributes except the designated attribute are retained, thereby completing the attribute configuration of the log4j log framework.
  • an embodiment of the present application provides a device for configuring attributes of a log4j log framework, including:
  • the attribute configuration instruction receiving unit 10 is configured to receive an attribute configuration instruction to the log4j log framework, and the attribute configuration instruction carries a specified attribute value;
  • the configuration file retrieval unit 20 is configured to retrieve a preset configuration file according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable Placeholders refer to special symbols that represent designated system variables;
  • the designated attribute value judgment unit 30 is configured to obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
  • the attribute value editing unit 40 is configured to, if the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
  • the update unit 50 is configured to call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  • This application uses designated system variable placeholders, and when the attributes need to be modified, only the designated system variables can be edited accordingly, thereby overcoming the shortcomings of time-consuming and inability to quickly take effect caused by restarting the server.
  • an attribute configuration instruction to the log4j log framework is received, and the attribute configuration instruction carries a specified attribute value.
  • the attribute configuration instruction is used to instruct to configure the attributes of the log4j log framework, for example, to configure attributes such as log level and log file storage path, with the purpose of configuring the specified attribute to be the specified attribute value carried by the attribute configuration instruction.
  • a preset configuration file is called, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder Symbols refer to special symbols that represent specified system variables.
  • the configuration of properties requires the use of preset configuration files to obtain the property values to be configured.
  • a designated system variable placeholder is set at the position of the designated attribute in the configuration file, so that when the attribute needs to be modified, only the designated system variable can be edited accordingly, and the configuration file does not need to be modified.
  • placeholders are symbols that occupy a fixed position and wait for you to add content to them; and system variable placeholders are special symbols that represent system variables; system variables refer to the data storage location defined by the system. Recorded data.
  • system variable placeholders are not ordinary placeholders, because the system variable placeholders represent system variables, and the system variables can be edited without opening the configuration file, so that the configuration file is not modified. The modification of attributes therefore avoids the disadvantages of time-consuming and unable to take effect quickly due to the need to restart the server during attribute configuration (modification) in the traditional method.
  • the state of the system variable placeholder in the configuration file is, for example: all attribute positions in the configuration file are occupied by system variable placeholders; or, there is only designated The attribute position is occupied by a system variable placeholder; or, other attribute positions in the configuration file except the specified attribute position record the attribute value or are occupied by the system variable placeholder.
  • the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value.
  • the system variable placeholder is a special symbol representing the system variable. Therefore, the designated system variable can be obtained by querying the designated system variable placeholder. Then judge whether the specified system variable is the same as the specified attribute value; if the specified system variable is the same as the specified attribute value, that is, the current attribute value is the same as the specified attribute value, so no attribute update is required; If the system variable is different from the specified attribute value, an attribute update operation is required.
  • a preset system variable editing method is called to edit the designated system variable to the designated attribute value. If the specified system variable is different from the specified attribute value, an attribute update operation is required.
  • a method is also called a function, which is a collection of statements that perform a function together.
  • the system variable editing method is used to edit the system variable. Since the system variable editing method is preset, the system variable editing can be realized by directly calling this method.
  • the method for editing the system variable is, for example, obtaining the position of the system variable; deleting the system variable data; recording the pre-prepared variable data into the system variable position, so as to realize the editing of the system variable.
  • the preset configuration file loading method is invoked so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework .
  • the configuration file loading method is used to load a configuration file to update all or part of the attributes. Therefore, by calling the preset configuration file loading method, the attribute update operation can be performed, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attributes of the log4j log framework Configuration.
  • the device includes:
  • the attribute to be modified marking unit is used to count information about the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record attributes whose number of times of modification exceeds a preset number threshold as attributes to be modified;
  • the system variable placeholder setting unit is used to set the system variable placeholder in the position of the attribute to be modified in the configuration file.
  • the position of the tag attribute in the configuration file is set as a system variable placeholder. If some attributes of the log4j log framework are not frequently modified, then these attributes can be directly recorded in the configuration file with specific attribute values, and there is no need to use system variable placeholders. However, for attributes that have been modified more than the preset number threshold within a predetermined time, because they are often modified, system variable placeholders need to be used. Thus, the attributes in the configuration file are divided into specific attribute values or system variable placeholders according to the number of times they have been modified, thereby reducing the increase in system burden caused by all use of system variable placeholders in the configuration file ( System variable placeholders take up more space) defects.
  • the designated attribute value judgment unit 30 includes:
  • the designated system variable obtaining subunit is configured to obtain the designated system variable by using the designated system variable placeholder according to the corresponding relationship between the preset system variable placeholder and the system variable;
  • the similarity value calculation subunit is used to calculate the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm
  • the dissimilar determination subunit is configured to determine that the specified system variable is not the same as the specified attribute value if the similarity value is less than a preset similarity threshold.
  • the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value.
  • the preset similarity algorithm is, for example, the WMD algorithm (word move's distance), the simhash algorithm, and the algorithm based on cosine similarity and word frequency vector similarity.
  • the foregoing algorithms are all mature algorithms and will not be repeated here. If the similarity value is less than the preset similarity threshold, it is determined that the specified system variable is not the same as the specified attribute value; if the similarity value is not less than the preset similarity threshold, it is determined that the specified The system variable is the same as the specified attribute value.
  • the purpose of this embodiment is to be compatible with the miswriting of the specified attribute value carried by the attribute configuration instruction. For example, if DEBUG is mistakenly written as DEBAG, the similarity algorithm according to this embodiment will determine that the two are the same, so there is no need to update the attribute. This avoids the use of ordinary text comparison methods (comparing characters one by one, if there is a difference, the judgment is not the same) to judge the two as different, which will lead to the subsequent incorrect unrecognizable DEBAG (DEBUG is the log level, and DEBAG is not) Set to the attribute value of the log4j log frame, causing serious errors.
  • the similarity value calculation subunit includes:
  • the preset similarity algorithm is used to calculate the similarity value between the designated system variable and the designated attribute value.
  • the similarity algorithm is calculated according to the cosine similarity between the designated system variable and the designated attribute value, so as to reflect the degree of similarity between the designated system variable and the designated attribute value. When the value of similarity is closer to 1, the more similar is; the closer to 0, the less similar.
  • the attribute value editing unit 40 includes:
  • a permission judgment subunit configured to judge whether the user account sending the attribute configuration instruction is in a preset permission user list if the specified system variable is not the same as the specified attribute value
  • the parameter range determination subunit is configured to determine whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account that sends the attribute configuration instruction is in the preset list of authorized users;
  • the attribute value editing subunit is configured to, if the specified attribute value does not exceed the preset parameter range of the specified system variable, call a preset system variable editing method to edit the specified system variable to the specified attribute value.
  • the user accounts in the preset list of authorized users have the authority to edit system variables, so as to reduce the possibility of system variables being tampered with.
  • the preset parameter range limits the parameter content that the specified system variable can be set.
  • the log level can be set to five levels: DEBUG, INFO, WARN, ERROR and FATAL, that is, the preset parameter range is DEBUG, INFO, WARN , ERROR and FATAL. Therefore, authorization verification and parameter verification are performed first to reduce the possibility of attribute configuration errors.
  • the attribute value editing unit 40 includes:
  • the reminder information generating subunit is configured to generate reminder information of parameter errors if the specified attribute value exceeds the preset parameter range of the specified system variable;
  • the reminder information return subunit is used to return the reminder information of the parameter error to the terminal that sends the attribute configuration instruction of the log4j log frame.
  • the reminder information of the parameter error is returned to the terminal that sends the attribute configuration instruction of the log4j log framework.
  • the specified attribute value exceeds the preset parameter range of the specified system variable, the specified attribute value cannot be configured, otherwise it will cause an error in the log4j log framework.
  • the preset parameter range of the log level is DEBUG, INFO, WARN , ERROR and FATAL, and the specified attribute value is right, which exceeds the preset parameter range of the specified system variable, a warning message of parameter error should be generated, and the warning message of the parameter error should be returned to the sender of the log4j log frame The terminal of the attribute configuration command.
  • the attributes other than the specified attributes in the configuration file record preset attribute values includes:
  • the loading method calling subunit is used to call a preset configuration file loading method, and according to the configuration file, update the specified attribute of the log4j log frame to the specified attribute value;
  • the value retention sub-unit of other attributes is used to retain the values of the other attributes except the specified attributes, so as to complete the attribute configuration of the log4j log framework.
  • the property configuration of the log4j log framework is completed.
  • other attributes in the configuration file other than the specified attribute record the preset attribute value, so there is no need to update the other attributes when performing attribute configuration (attribute update) (so the configuration file is not modified, so It is impossible to change other attributes), which reduces the amount of calculation and improves the speed of attribute configuration. Accordingly, only the designated attribute of the log4j log framework is updated to the designated attribute value, and the values of the other attributes except the designated attribute are retained, thereby completing the attribute configuration of the log4j log framework.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in the figure.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the memory provides an environment for the operation of the operating system and computer readable instructions in the non-volatile storage medium.
  • the database of the computer equipment is used to store the data used in the attribute configuration method of the log4j log framework.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the processor executes the attribute configuration method of the log4j log framework, including the following steps: receiving an attribute configuration instruction for the log4j log framework, the attribute configuration instruction carrying a specified attribute value; according to the attribute configuration instruction, calling a preset A configuration file, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to a special symbol representing a designated system variable; the designated system variable placeholder is used Obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value; if the designated system variable is not the same as the designated attribute value, call the preset system variable editing method to change the The specified system variable is edited as the specified attribute value; the preset configuration file loading method is called, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the log4j log The attribute configuration of the framework.
  • the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies
  • the position symbol refers to the special symbol representing the designated system variable before the step, including: counting the number of times the attribute of the log4j log frame has been modified within a predetermined time, and recording the attribute whose number of times of modification exceeds the preset number threshold as the attribute to be modified; Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
  • the step of obtaining the designated system variable by using the designated system variable placeholder and determining whether the designated system variable is the same as the designated attribute value includes: according to a preset system variable The corresponding relationship between the placeholder and the system variable, using the designated system variable placeholder to obtain the designated system variable; using a preset similarity algorithm to calculate the similarity value between the designated system variable and the designated attribute value; If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
  • the step of calculating the similarity value between the specified system variable and the specified attribute value by using a preset similarity algorithm includes: using a formula:
  • the step of calling a preset system variable editing method to edit the designated system variable to the designated attribute value if the designated system variable is different from the designated attribute value includes: If the specified system variable is not the same as the specified attribute value, it is determined whether the user account that sends the attribute configuration instruction is in the preset list of authorized users; if the user account that sends the attribute configuration instruction is in the preset In the list of authorized users, determine whether the specified attribute value exceeds the preset parameter range of the specified system variable; if the specified attribute value does not exceed the preset parameter range of the specified system variable, call the preset system The variable editing method edits the designated system variable to the designated attribute value.
  • the step of judging whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account sending the attribute configuration instruction is in a preset list of authorized users Including: if the specified attribute value exceeds the preset parameter range of the specified system variable, generating a parameter error reminder message; returning the parameter error reminder message to the terminal that sent the log4j log frame attribute configuration instruction .
  • the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file
  • the step of updating the current attribute value to the specified attribute value to complete the attribute configuration of the log4j log framework includes: calling a preset configuration file loading method, and assigning the log4j log framework to the specified configuration file according to the configuration file
  • the attribute is updated to the specified attribute value; the values of the other attributes except the specified attribute are retained, thereby completing the attribute configuration of the log4j log framework.
  • An embodiment of the present application also provides a computer-readable storage medium on which computer-readable instructions are stored.
  • a method for configuring attributes of the log4j log framework is implemented, including the following steps: receiving log4j logs
  • the attribute configuration instruction of the framework the attribute configuration instruction carries a specified attribute value; according to the attribute configuration instruction, a preset configuration file is called, wherein a specified system variable is set in the position of the specified attribute in the configuration file
  • the designated system variable placeholder refers to a special symbol representing a designated system variable; the designated system variable placeholder is used to obtain the designated system variable, and it is judged whether the designated system variable is the same as the designated attribute value The same; if the specified system variable is not the same as the specified attribute value, call the preset system variable editing method to edit the specified system variable to the specified attribute value; call the preset configuration file loading method to Make the log4j log framework update the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j
  • the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies
  • the position symbol refers to the special symbol representing the designated system variable before the step, including: counting the number of times the attribute of the log4j log frame has been modified within a predetermined time, and recording the attribute whose number of times of modification exceeds the preset number threshold as the attribute to be modified; Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
  • the step of obtaining the designated system variable by using the designated system variable placeholder and determining whether the designated system variable is the same as the designated attribute value includes: according to a preset system variable The corresponding relationship between the placeholder and the system variable, using the designated system variable placeholder to obtain the designated system variable; using a preset similarity algorithm to calculate the similarity value between the designated system variable and the designated attribute value; If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
  • the step of calculating the similarity value between the specified system variable and the specified attribute value by using a preset similarity algorithm includes: using a formula:
  • the step of calling a preset system variable editing method to edit the designated system variable to the designated attribute value if the designated system variable is different from the designated attribute value includes: If the specified system variable is not the same as the specified attribute value, it is determined whether the user account that sends the attribute configuration instruction is in the preset list of authorized users; if the user account that sends the attribute configuration instruction is in the preset In the list of authorized users, determine whether the specified attribute value exceeds the preset parameter range of the specified system variable; if the specified attribute value does not exceed the preset parameter range of the specified system variable, call the preset system The variable editing method edits the designated system variable to the designated attribute value.
  • the step of judging whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account sending the attribute configuration instruction is in a preset list of authorized users Including: if the specified attribute value exceeds the preset parameter range of the specified system variable, generating a parameter error reminder message; returning the parameter error reminder message to the terminal that sent the log4j log frame attribute configuration instruction .
  • the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file
  • the step of updating the current attribute value to the specified attribute value to complete the attribute configuration of the log4j log framework includes: calling a preset configuration file loading method, and assigning the log4j log framework to the specified configuration file according to the configuration file
  • the attribute is updated to the specified attribute value; the values of the other attributes except the specified attribute are retained, thereby completing the attribute configuration of the log4j log framework.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • ROM read only memory
  • PROM programmable ROM
  • EPROM electrically programmable ROM
  • EEPROM electrically erasable programmable ROM
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

An attribute configuration method and apparatus for a log4j log framework, and a computer device and a storage medium. The method comprises: receiving an attribute configuration instruction for a log4j log framework; according to the attribute configuration instruction, calling a pre-set configuration file, wherein a specified system variable placeholder is arranged at the position of a specified attribute in the configuration file; using the specified system variable placeholder to acquire a specified system variable; if the specified system variable is different from a specified attribute value, calling a pre-set system variable editing method to edit the specified system variable to be the specified attribute value; and calling a pre-set configuration file loading method, such that the log4j log framework updates, according to the configuration file, the current attribute value to be the specified attribute value, thereby completing attribute configuration of the log4j log framework. Therefore, real-time attribute configuration is realized on a log4j log framework, and the technical problems of attribute configuration taking a long time and being unable to take effect quickly are solved.

Description

log4j日志框架的属性配置方法、装置和计算机设备Attribute configuration method, device and computer equipment of log4j log frame
本申请要求于2019年5月30日提交中国专利局、申请号为2019104636428,发明名称为“log4j日志框架的属性配置方法、装置和计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on May 30, 2019, with application number 2019104636428, and the title of the invention "log4j log framework attribute configuration method, device and computer equipment", the entire content of which is by reference Incorporated in this application.
技术领域Technical field
本申请涉及到计算机领域,特别是涉及到一种log4j日志框架的属性配置方法、装置、计算机设备和存储介质。This application relates to the computer field, and in particular to a method, device, computer equipment, and storage medium for configuring log4j log framework attributes.
背景技术Background technique
在计算机领域中,日志记录经常被使用,例如线上问题追踪,基于日志的业务逻辑统计分析等都离不开日志。日志框架有多种,其中log4j日志框架是常用的一种。目前现有技术对于log4j日志框架进行属性配置(例如属性修改)时,需要在相关的配置文件对属性内容进行修改,因此需要重启服务器,使得属性配置(例如属性修改)耗时长及无法快速生效。因此,现有技术缺乏能够对log4j日志框架进行即时属性配置,解决属性配置耗时长及无法快速生效的技术问题的方案。In the computer field, log records are often used. For example, online problem tracking, log-based business logic statistical analysis, etc. are inseparable from logs. There are many log frameworks, among which log4j log framework is a commonly used one. At present, when performing attribute configuration (for example, attribute modification) to the log4j log framework in the prior art, the attribute content needs to be modified in the related configuration file. Therefore, the server needs to be restarted, making attribute configuration (for example, attribute modification) time-consuming and unable to take effect quickly. Therefore, the prior art lacks a solution that can perform real-time attribute configuration on the log4j log framework and solve the technical problem that attribute configuration takes a long time and cannot take effect quickly.
技术问题technical problem
本申请的主要目的为提供一种log4j日志框架的属性配置方法、装置、计算机设备和存储介质,旨在解决属性配置耗时长及无法快速生效的技术问题。The main purpose of this application is to provide a log4j log framework attribute configuration method, device, computer equipment and storage medium, aiming to solve the technical problem that attribute configuration takes a long time and cannot take effect quickly.
技术解决方案Technical solutions
为了实现上述目的,本申请提出一种log4j日志框架的属性配置方法,包括以下步骤:In order to achieve the above purpose, this application proposes a method for configuring the attributes of the log4j log framework, which includes the following steps:
接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;Receiving an attribute configuration instruction to the log4j log framework, where the attribute configuration instruction carries a specified attribute value;
根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;According to the attribute configuration instruction, a preset configuration file is retrieved, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to the designated system variable Special symbol
利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;Using the designated system variable placeholder to obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value;
若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;If the designated system variable is not the same as the designated attribute value, calling a preset system variable editing method to edit the designated system variable to the designated attribute value;
调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。Calling a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
本申请提供一种log4j日志框架的属性配置装置,包括:This application provides an attribute configuration device of log4j log framework, including:
属性配置指令接收单元,用于接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;The attribute configuration instruction receiving unit is configured to receive an attribute configuration instruction to the log4j log framework, and the attribute configuration instruction carries a specified attribute value;
配置文件调取单元,用于根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指 定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;The configuration file retrieval unit is configured to retrieve a preset configuration file according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable accounts for Bit symbol refers to the special symbol that represents the specified system variable;
指定属性值判断单元,用于利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;The designated attribute value judgment unit is configured to obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
属性值编辑单元,用于若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;The attribute value editing unit is configured to, if the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
更新单元,用于调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。The update unit is configured to call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
本申请提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现上述任一项所述方法的步骤。The present application provides a computer device including a memory and a processor, the memory stores computer readable instructions, and the processor implements the steps of any one of the above methods when the computer readable instructions are executed.
本申请提供一种计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述任一项所述的方法的步骤。The present application provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of any of the above methods are implemented.
有益效果Beneficial effect
本申请的log4j日志框架的属性配置方法、装置、计算机设备和存储介质,接收对log4j日志框架的属性配置指令;调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符;利用所述指定系统变量占位符获取所述指定系统变量;若所述指定系统变量与所述指定属性值不相同,则将所述指定系统变量编辑为所述指定属性值;调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值。从而实现了对log4j日志框架进行即时属性配置,解决了属性配置耗时长及无法快速生效的技术问题。The attribute configuration method, device, computer equipment and storage medium of the log4j log framework of this application receive an attribute configuration instruction for the log4j log framework; call a preset configuration file, where the specified attribute in the configuration file is set at the position There is a designated system variable placeholder; the designated system variable is obtained by using the designated system variable placeholder; if the designated system variable is different from the designated attribute value, the designated system variable is edited as the Specify the attribute value; call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file. In this way, real-time attribute configuration of the log4j log framework is realized, and the technical problem that attribute configuration takes a long time and cannot take effect quickly is solved.
附图说明Description of the drawings
图1为本申请一实施例的log4j日志框架的属性配置方法的流程示意图;FIG. 1 is a schematic flowchart of an attribute configuration method of the log4j log framework according to an embodiment of the application;
图2为本申请一实施例的log4j日志框架的属性配置装置的结构示意框图;2 is a schematic block diagram of the structure of a device for configuring an attribute of a log4j log framework according to an embodiment of the application;
图3为本申请一实施例的计算机设备的结构示意框图。FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
本申请的最佳实施方式The best implementation of this application
参照图1,本申请实施例提供一种log4j日志框架的属性配置方法,包括以下步骤:1, an embodiment of the present application provides a method for configuring attributes of the log4j log framework, including the following steps:
S1、接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;S1. Receive an attribute configuration instruction to the log4j log framework, where the attribute configuration instruction carries a specified attribute value;
S2、根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;S2. According to the attribute configuration instruction, retrieve a preset configuration file, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to a designated system Special symbols for variables;
S3、利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;S3. Obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
S4、若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;S4. If the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
S5、调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。S5. Invoke a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
本申请利用指定系统变量占位符,当需要修改属性时,仅对指定系统变量进行相应编辑即可,从而克服了重启服务器导致的耗时长及无法快速生效的缺陷。This application uses designated system variable placeholders, and when the attributes need to be modified, only the designated system variables can be edited accordingly, thereby overcoming the shortcomings of time-consuming and inability to quickly take effect caused by restarting the server.
如上述步骤S1所述,接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值。其中属性配置指令用于指示对log4j日志框架的属性进行配置,例如对日志级别、日志文件的保存路径等属性进行配置,目的在于使指定属性被配置为所述属性配置指令携带的指定属性值。As described in step S1 above, an attribute configuration instruction to the log4j log framework is received, and the attribute configuration instruction carries a specified attribute value. The attribute configuration instruction is used to instruct to configure the attributes of the log4j log framework, for example, to configure attributes such as log level and log file storage path, with the purpose of configuring the specified attribute to be the specified attribute value carried by the attribute configuration instruction.
如上述步骤S2所述,根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号。对于log4j日志框架而言,进行属性配置需要利用预设的配置文件以获得将要配置的属性值。本申请在所述配置文件中的指定属性的位置上设置有指定系统变量占位符,从而当需要修改属性时,仅对指定系统变量进行相应编辑即可,无需对所述配置文件进行修改。其中,占位符就是先占住一个固定的位置,等着你再往里面添加内容的符号;而系统变量占位符则是代表系统变量的特殊符号;系统变量指由系统定义的数据存储位置所记载的数据。并且,所述系统变量占位符并非是普通的占位符,由于系统变量占位符代表系统变量,而系统变量可不通过打开配置文件即可进行编辑,从而实现在不修改配置文件的前提下对属性的修改,因此避免了传统方法在属性配置(修改)时,需要进行重启服务器导致的耗时长及无法快速生效的缺陷。其中,所述系统变量占位符在所述配置文件中的状态例如为:所述配置文件中的所有属性位置均使用系统变量占位符进行占位;或者,所述配置文件中仅有指定属性位置使用系统变量占位符进行占位;或者,所述配置文件中的除所述指定属性位置之外的其他属性位置记载了属性值或者被系统变量占位符进行占位。As described in step S2 above, according to the attribute configuration instruction, a preset configuration file is called, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder Symbols refer to special symbols that represent specified system variables. For the log4j logging framework, the configuration of properties requires the use of preset configuration files to obtain the property values to be configured. In this application, a designated system variable placeholder is set at the position of the designated attribute in the configuration file, so that when the attribute needs to be modified, only the designated system variable can be edited accordingly, and the configuration file does not need to be modified. Among them, placeholders are symbols that occupy a fixed position and wait for you to add content to them; and system variable placeholders are special symbols that represent system variables; system variables refer to the data storage location defined by the system. Recorded data. Moreover, the system variable placeholders are not ordinary placeholders, because the system variable placeholders represent system variables, and the system variables can be edited without opening the configuration file, so that the configuration file is not modified. The modification of attributes therefore avoids the disadvantages of time-consuming and unable to take effect quickly due to the need to restart the server during attribute configuration (modification) in the traditional method. Wherein, the state of the system variable placeholder in the configuration file is, for example: all attribute positions in the configuration file are occupied by system variable placeholders; or, there is only designated The attribute position is occupied by a system variable placeholder; or, other attribute positions in the configuration file except the specified attribute position record the attribute value or are occupied by the system variable placeholder.
如上述步骤S3所述,利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同。由前述,系统变量占位符则是代表系统变量的特殊符号,因此通过查询所述指定系统变量占位符即可获知所述指定系统变量。再判断所述指定系统变量是否与所述指定属性值相同;若所述指定系统变量与所述指定属性值相同,即当前属性值与指定属性值相同,因此无需进行属性更新;若所述指定系统变量与所述指定属性值不相同,则需进行属性更新操作。As described in step S3 above, the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value. From the foregoing, the system variable placeholder is a special symbol representing the system variable. Therefore, the designated system variable can be obtained by querying the designated system variable placeholder. Then judge whether the specified system variable is the same as the specified attribute value; if the specified system variable is the same as the specified attribute value, that is, the current attribute value is the same as the specified attribute value, so no attribute update is required; If the system variable is different from the specified attribute value, an attribute update operation is required.
如上述步骤S4所述,若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。若所述指定系统变量与所述指定属性值不相同,则需要进行属性更新操作。其中方法也被称为函数,是语句的集合,它们在一起执行一个功能。所述系统变量编辑方法用于编辑所述系统变量。由于系统变量编辑方法是预先设置好的,因此直接调用该方法即可实现系统变量编辑。其中系统变量编辑方法例如为:获取系统变量位置;删除所述系统变量数据;将预先准备的变量数据记载入所述系统变量位置,从而实现系统变量编辑。As described in step S4 above, if the designated system variable is different from the designated attribute value, a preset system variable editing method is called to edit the designated system variable to the designated attribute value. If the specified system variable is different from the specified attribute value, an attribute update operation is required. A method is also called a function, which is a collection of statements that perform a function together. The system variable editing method is used to edit the system variable. Since the system variable editing method is preset, the system variable editing can be realized by directly calling this method. The method for editing the system variable is, for example, obtaining the position of the system variable; deleting the system variable data; recording the pre-prepared variable data into the system variable position, so as to realize the editing of the system variable.
如上述步骤S5所述,调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。其中所述配置文件加载方法用于加载配置文件,以更新所有或者部分属性。因此调用预设的配置文件加载方法,便可进行属性更新操作,从而使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。As described in step S5 above, call the preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework . The configuration file loading method is used to load a configuration file to update all or part of the attributes. Therefore, by calling the preset configuration file loading method, the attribute update operation can be performed, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attributes of the log4j log framework Configuration.
在一个实施方式中,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤S2之前,包括:In one embodiment, the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies Place symbol refers to the special symbol representing the designated system variable before step S2, including:
S11、统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;S11. Count information about the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record the attributes whose number of times have been modified over a preset number threshold as attributes to be modified;
S12、将所述配置文件中的待修改属性的位置设置系统变量占位符。S12. Set a system variable placeholder in the position of the attribute to be modified in the configuration file.
如上所述,实现了将所述配置文件中的标记属性的位置设置系统变量占位符。若所述log4j日志框架的某些属性并不经常被修改,那么在所述配置文件中将这些属性直接采用具体的属性值进行记载即可,并不需要使用系统变量占位符。然而对于预定时间内被修改次数超过预设数量阈值的属性,由于常被修改,因此需要使用系统变量占位符。从而将所述配置文件中的属性按被修改次数分为记载为具体属性值或者系统变量占位符,从而减少了在所述配置文件中全部使用系统变量占位符将导致的系统负担增加(系统变量占位符占用空间更大)的缺陷。As described above, it is achieved that the position of the tag attribute in the configuration file is set as a system variable placeholder. If some attributes of the log4j log framework are not frequently modified, then these attributes can be directly recorded in the configuration file with specific attribute values, and there is no need to use system variable placeholders. However, for attributes that have been modified more than the preset number threshold within a predetermined time, because they are often modified, system variable placeholders need to be used. Thus, the attributes in the configuration file are divided into specific attribute values or system variable placeholders according to the number of times they have been modified, thereby reducing the increase in system burden caused by all use of system variable placeholders in the configuration file ( System variable placeholders take up more space) defects.
在一个实施方式中,所述利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤S3,包括:In one embodiment, the step S3 of obtaining the designated system variable by using the designated system variable placeholder, and determining whether the designated system variable is the same as the designated attribute value, includes:
S301、根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;S301: Acquire the designated system variable by using the designated system variable placeholder according to the preset correspondence between the system variable placeholder and the system variable;
S302、采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;S302: Calculate the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm;
S303、若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。S303: If the similarity degree value is less than a preset similarity degree threshold, determine that the designated system variable is different from the designated attribute value.
如上所述,实现了利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同。其中,预设的相似度算法例如为WMD算法(word mover’s distance)、simhash算法、基于余弦相似度、词频向量相似度的算法,上述算法均为成熟算法,在此不再赘述。若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同;若所述相似程度值不小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值相同。本实施方式目的在于兼容所述属性配置指令携带的指定属性值的误写,例如将DEBUG误写为DEBAG,根据本实施方式的相似度算法将判定二者相同,因此不必进行更新属性的操作,从而避免采用普通的文本比对方式(逐 一比对字符,若有一处不同即判定不相同)将二者判定不同,而导致后续将错误的不可识别的DEBAG(DEBUG是日志级别,而DEBAG不是)设置为所述log4j日志框架的属性值,造成严重错误。As described above, it is achieved that the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value. Among them, the preset similarity algorithm is, for example, the WMD algorithm (word move's distance), the simhash algorithm, and the algorithm based on cosine similarity and word frequency vector similarity. The foregoing algorithms are all mature algorithms and will not be repeated here. If the similarity value is less than the preset similarity threshold, it is determined that the specified system variable is not the same as the specified attribute value; if the similarity value is not less than the preset similarity threshold, it is determined that the specified The system variable is the same as the specified attribute value. The purpose of this embodiment is to be compatible with the miswriting of the specified attribute value carried by the attribute configuration instruction. For example, if DEBUG is mistakenly written as DEBAG, the similarity algorithm according to this embodiment will determine that the two are the same, so there is no need to update the attribute. This avoids the use of ordinary text comparison methods (comparing characters one by one, if there is a difference, the judgment is not the same) to judge the two as different, which will lead to the subsequent incorrect unrecognizable DEBAG (DEBUG is the log level, and DEBAG is not) Set to the attribute value of the log4j log frame, causing serious errors.
在一个实施方式中,所述采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值的步骤S302,包括:In one embodiment, the step S302 of calculating the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm includes:
S3021、采用公式:S3021, adopt the formula:
Figure PCTCN2019117667-appb-000001
Figure PCTCN2019117667-appb-000001
计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
如上所述,实现了采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值。所述字符频率向量是以所述指定系统变量或者所述指定属性值的各个字符出现的次数(频率)作为向量的维度数值,所构成的多维向量。即A=(A1,A2,…,An),其中An为最后一个字符(共有n个字符)出现的次数。所述相似度算法是根据所述指定系统变量与所述指定属性值的余弦相似度进行计算得到,以反应所述指定系统变量与所述指定属性值的相似程度。当similarity的值越接近于1,表明越相似;越接近于0,表明越不相似。As described above, it is realized that the preset similarity algorithm is used to calculate the similarity value between the designated system variable and the designated attribute value. The character frequency vector is a multidimensional vector formed by taking the number of times (frequency) of each character of the designated system variable or the designated attribute value as the dimensional value of the vector. That is, A=(A1,A2,...,An), where An is the number of times the last character (a total of n characters) appears. The similarity algorithm is calculated according to the cosine similarity between the designated system variable and the designated attribute value, so as to reflect the degree of similarity between the designated system variable and the designated attribute value. When the value of similarity is closer to 1, the more similar is; the closer to 0, the less similar.
在一个实施方式中,所述若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值的步骤S4,包括:In one embodiment, if the designated system variable is not the same as the designated attribute value, the step S4 of calling a preset system variable editing method to edit the designated system variable to the designated attribute value includes :
S401、若所述指定系统变量与所述指定属性值不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;S401: If the specified system variable is not the same as the specified attribute value, determine whether the user account sending the attribute configuration instruction is in a preset list of authorized users;
S402、若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;S402: If the user account sending the attribute configuration instruction is in the preset list of authorized users, determine whether the specified attribute value exceeds the preset parameter range of the specified system variable;
S403、若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。S403: If the specified attribute value does not exceed the preset parameter range of the specified system variable, call a preset system variable editing method to edit the specified system variable to the specified attribute value.
如上所述,实现了在调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值之前,进行权限验证与参数验证。其中,预设的权限用户列表中的用户账户具有对系统变量进行编辑的权限,以减少系统变量被篡改的可能性。预设参数范围限定了所述指定系统变量能够被设置的参数内容,例如日志级别可被设置为五个级别:DEBUG、INFO、WARN、ERROR和FATAL,即预设参数范围为DEBUG、INFO、WARN、ERROR和FATAL。从而先进行权限验证与参数验证,以减少属性配置发生错误的可能性。As described above, before calling the preset system variable editing method to edit the designated system variable to the designated attribute value, authorization verification and parameter verification are implemented. Among them, the user accounts in the preset list of authorized users have the authority to edit system variables, so as to reduce the possibility of system variables being tampered with. The preset parameter range limits the parameter content that the specified system variable can be set. For example, the log level can be set to five levels: DEBUG, INFO, WARN, ERROR and FATAL, that is, the preset parameter range is DEBUG, INFO, WARN , ERROR and FATAL. Therefore, authorization verification and parameter verification are performed first to reduce the possibility of attribute configuration errors.
在一个实施方式中,所述若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围的步骤S402之后,包括:In one embodiment, if the user account that sends the attribute configuration instruction is in the preset list of authorized users, after the step S402 of determining whether the specified attribute value exceeds the preset parameter range of the specified system variable ,include:
S4021、若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;S4021. If the specified attribute value exceeds the preset parameter range of the specified system variable, generate a parameter error warning message;
S4022、将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。S4022. Return the warning message of the parameter error to the terminal that sent the attribute configuration instruction of the log4j log frame.
如上所述,实现了将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。若所述指定属性值超出所述指定系统变量的预设参数范围,则所述指定属性值不能进行配置,否则将导致log4j日志框架出错,例如日志级别的预设参数范围为DEBUG、INFO、WARN、ERROR和FATAL,而指定属性值为right,超出所述指定系统变量的预设参数范围,则应生成参数错误的提醒信息,将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。As described above, it is realized that the reminder information of the parameter error is returned to the terminal that sends the attribute configuration instruction of the log4j log framework. If the specified attribute value exceeds the preset parameter range of the specified system variable, the specified attribute value cannot be configured, otherwise it will cause an error in the log4j log framework. For example, the preset parameter range of the log level is DEBUG, INFO, WARN , ERROR and FATAL, and the specified attribute value is right, which exceeds the preset parameter range of the specified system variable, a warning message of parameter error should be generated, and the warning message of the parameter error should be returned to the sender of the log4j log frame The terminal of the attribute configuration command.
在一个实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置的步骤S5,包括:In one embodiment, the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file Updating the current attribute value to the designated attribute value to complete the step S5 of the attribute configuration of the log4j log framework includes:
S501、调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;S501. Invoke a preset configuration file loading method, and update the specified attribute of the log4j log frame to the specified attribute value according to the configuration file;
S502、将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。S502. Keep the values of the attributes other than the specified attributes, so as to complete the attribute configuration of the log4j log framework.
如上所述,实现了完成所述log4j日志框架的属性配置。本实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,因此在进行属性配置(属性更新)时无需更新所述其他属性(因此配置文件未修改,因此其他属性不可能发生改变),从而减少了计算量,提高了属性配置速度。据此,仅将所述log4j日志框架的指定属性更新为所述指定属性值,将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。As mentioned above, the property configuration of the log4j log framework is completed. In this embodiment, other attributes in the configuration file other than the specified attribute record the preset attribute value, so there is no need to update the other attributes when performing attribute configuration (attribute update) (so the configuration file is not modified, so It is impossible to change other attributes), which reduces the amount of calculation and improves the speed of attribute configuration. Accordingly, only the designated attribute of the log4j log framework is updated to the designated attribute value, and the values of the other attributes except the designated attribute are retained, thereby completing the attribute configuration of the log4j log framework.
参照图2,本申请实施例提供一种log4j日志框架的属性配置装置,包括:Referring to FIG. 2, an embodiment of the present application provides a device for configuring attributes of a log4j log framework, including:
属性配置指令接收单元10,用于接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;The attribute configuration instruction receiving unit 10 is configured to receive an attribute configuration instruction to the log4j log framework, and the attribute configuration instruction carries a specified attribute value;
配置文件调取单元20,用于根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;The configuration file retrieval unit 20 is configured to retrieve a preset configuration file according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable Placeholders refer to special symbols that represent designated system variables;
指定属性值判断单元30,用于利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;The designated attribute value judgment unit 30 is configured to obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
属性值编辑单元40,用于若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;The attribute value editing unit 40 is configured to, if the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
更新单元50,用于调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当 前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。The update unit 50 is configured to call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
本申请利用指定系统变量占位符,当需要修改属性时,仅对指定系统变量进行相应编辑即可,从而克服了重启服务器导致的耗时长及无法快速生效的缺陷。This application uses designated system variable placeholders, and when the attributes need to be modified, only the designated system variables can be edited accordingly, thereby overcoming the shortcomings of time-consuming and inability to quickly take effect caused by restarting the server.
如上述单元10所述,接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值。其中属性配置指令用于指示对log4j日志框架的属性进行配置,例如对日志级别、日志文件的保存路径等属性进行配置,目的在于使指定属性被配置为所述属性配置指令携带的指定属性值。As described in the aforementioned unit 10, an attribute configuration instruction to the log4j log framework is received, and the attribute configuration instruction carries a specified attribute value. The attribute configuration instruction is used to instruct to configure the attributes of the log4j log framework, for example, to configure attributes such as log level and log file storage path, with the purpose of configuring the specified attribute to be the specified attribute value carried by the attribute configuration instruction.
如上述单元20所述,根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号。对于log4j日志框架而言,进行属性配置需要利用预设的配置文件以获得将要配置的属性值。本申请在所述配置文件中的指定属性的位置上设置有指定系统变量占位符,从而当需要修改属性时,仅对指定系统变量进行相应编辑即可,无需对所述配置文件进行修改。其中,占位符就是先占住一个固定的位置,等着你再往里面添加内容的符号;而系统变量占位符则是代表系统变量的特殊符号;系统变量指由系统定义的数据存储位置所记载的数据。并且,所述系统变量占位符并非是普通的占位符,由于系统变量占位符代表系统变量,而系统变量可不通过打开配置文件即可进行编辑,从而实现在不修改配置文件的前提下对属性的修改,因此避免了传统方法在属性配置(修改)时,需要进行重启服务器导致的耗时长及无法快速生效的缺陷。其中,所述系统变量占位符在所述配置文件中的状态例如为:所述配置文件中的所有属性位置均使用系统变量占位符进行占位;或者,所述配置文件中仅有指定属性位置使用系统变量占位符进行占位;或者,所述配置文件中的除所述指定属性位置之外的其他属性位置记载了属性值或者被系统变量占位符进行占位。As described in the aforementioned unit 20, according to the attribute configuration instruction, a preset configuration file is called, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable placeholder Symbols refer to special symbols that represent specified system variables. For the log4j logging framework, the configuration of properties requires the use of preset configuration files to obtain the property values to be configured. In this application, a designated system variable placeholder is set at the position of the designated attribute in the configuration file, so that when the attribute needs to be modified, only the designated system variable can be edited accordingly, and the configuration file does not need to be modified. Among them, placeholders are symbols that occupy a fixed position and wait for you to add content to them; and system variable placeholders are special symbols that represent system variables; system variables refer to the data storage location defined by the system. Recorded data. Moreover, the system variable placeholders are not ordinary placeholders, because the system variable placeholders represent system variables, and the system variables can be edited without opening the configuration file, so that the configuration file is not modified. The modification of attributes therefore avoids the disadvantages of time-consuming and unable to take effect quickly due to the need to restart the server during attribute configuration (modification) in the traditional method. Wherein, the state of the system variable placeholder in the configuration file is, for example: all attribute positions in the configuration file are occupied by system variable placeholders; or, there is only designated The attribute position is occupied by a system variable placeholder; or, other attribute positions in the configuration file except the specified attribute position record the attribute value or are occupied by the system variable placeholder.
如上述单元30所述,利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同。由前述,系统变量占位符则是代表系统变量的特殊符号,因此通过查询所述指定系统变量占位符即可获知所述指定系统变量。再判断所述指定系统变量是否与所述指定属性值相同;若所述指定系统变量与所述指定属性值相同,即当前属性值与指定属性值相同,因此无需进行属性更新;若所述指定系统变量与所述指定属性值不相同,则需进行属性更新操作。As described in the above unit 30, the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value. From the foregoing, the system variable placeholder is a special symbol representing the system variable. Therefore, the designated system variable can be obtained by querying the designated system variable placeholder. Then judge whether the specified system variable is the same as the specified attribute value; if the specified system variable is the same as the specified attribute value, that is, the current attribute value is the same as the specified attribute value, so no attribute update is required; If the system variable is different from the specified attribute value, an attribute update operation is required.
如上述单元40所述,若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。若所述指定系统变量与所述指定属性值不相同,则需要进行属性更新操作。其中方法也被称为函数,是语句的集合,它们在一起执行一个功能。所述系统变量编辑方法用于编辑所述系统变量。由于系统变量编辑方法是预先设置好的,因此直接调用该方法即可实现系统变量编辑。其中系统变量编辑方法例如为:获取系统变量位置;删除所述系统变量数据;将预先准备的变量数据记载入所述系统变量位置,从而实现系统变量编辑。As described in the aforementioned unit 40, if the designated system variable is different from the designated attribute value, a preset system variable editing method is called to edit the designated system variable to the designated attribute value. If the specified system variable is different from the specified attribute value, an attribute update operation is required. A method is also called a function, which is a collection of statements that perform a function together. The system variable editing method is used to edit the system variable. Since the system variable editing method is preset, the system variable editing can be realized by directly calling this method. The method for editing the system variable is, for example, obtaining the position of the system variable; deleting the system variable data; recording the pre-prepared variable data into the system variable position, so as to realize the editing of the system variable.
如上述单元50所述,调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将 当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。其中所述配置文件加载方法用于加载配置文件,以更新所有或者部分属性。因此调用预设的配置文件加载方法,便可进行属性更新操作,从而使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。As described in the above unit 50, the preset configuration file loading method is invoked so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework . The configuration file loading method is used to load a configuration file to update all or part of the attributes. Therefore, by calling the preset configuration file loading method, the attribute update operation can be performed, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attributes of the log4j log framework Configuration.
在一个实施方式中,所述装置,包括:In one embodiment, the device includes:
待修改属性标记单元,用于统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;The attribute to be modified marking unit is used to count information about the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record attributes whose number of times of modification exceeds a preset number threshold as attributes to be modified;
系统变量占位符设置单元,用于将所述配置文件中的待修改属性的位置设置系统变量占位符。The system variable placeholder setting unit is used to set the system variable placeholder in the position of the attribute to be modified in the configuration file.
如上所述,实现了将所述配置文件中的标记属性的位置设置系统变量占位符。若所述log4j日志框架的某些属性并不经常被修改,那么在所述配置文件中将这些属性直接采用具体的属性值进行记载即可,并不需要使用系统变量占位符。然而对于预定时间内被修改次数超过预设数量阈值的属性,由于常被修改,因此需要使用系统变量占位符。从而将所述配置文件中的属性按被修改次数分为记载为具体属性值或者系统变量占位符,从而减少了在所述配置文件中全部使用系统变量占位符将导致的系统负担增加(系统变量占位符占用空间更大)的缺陷。As described above, it is achieved that the position of the tag attribute in the configuration file is set as a system variable placeholder. If some attributes of the log4j log framework are not frequently modified, then these attributes can be directly recorded in the configuration file with specific attribute values, and there is no need to use system variable placeholders. However, for attributes that have been modified more than the preset number threshold within a predetermined time, because they are often modified, system variable placeholders need to be used. Thus, the attributes in the configuration file are divided into specific attribute values or system variable placeholders according to the number of times they have been modified, thereby reducing the increase in system burden caused by all use of system variable placeholders in the configuration file ( System variable placeholders take up more space) defects.
在一个实施方式中,所述指定属性值判断单元30,包括:In one embodiment, the designated attribute value judgment unit 30 includes:
指定系统变量获取子单元,用于根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;The designated system variable obtaining subunit is configured to obtain the designated system variable by using the designated system variable placeholder according to the corresponding relationship between the preset system variable placeholder and the system variable;
相似程度值计算子单元,用于采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;The similarity value calculation subunit is used to calculate the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm;
不相同判定子单元,用于若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。The dissimilar determination subunit is configured to determine that the specified system variable is not the same as the specified attribute value if the similarity value is less than a preset similarity threshold.
如上所述,实现了利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同。其中,预设的相似度算法例如为WMD算法(word mover’s distance)、simhash算法、基于余弦相似度、词频向量相似度的算法,上述算法均为成熟算法,在此不再赘述。若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同;若所述相似程度值不小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值相同。本实施方式目的在于兼容所述属性配置指令携带的指定属性值的误写,例如将DEBUG误写为DEBAG,根据本实施方式的相似度算法将判定二者相同,因此不必进行更新属性的操作,从而避免采用普通的文本比对方式(逐一比对字符,若有一处不同即判定不相同)将二者判定不同,而导致后续将错误的不可识别的DEBAG(DEBUG是日志级别,而DEBAG不是)设置为所述log4j日志框架的属性值,造成严重错误。As described above, it is achieved that the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value. Among them, the preset similarity algorithm is, for example, the WMD algorithm (word move's distance), the simhash algorithm, and the algorithm based on cosine similarity and word frequency vector similarity. The foregoing algorithms are all mature algorithms and will not be repeated here. If the similarity value is less than the preset similarity threshold, it is determined that the specified system variable is not the same as the specified attribute value; if the similarity value is not less than the preset similarity threshold, it is determined that the specified The system variable is the same as the specified attribute value. The purpose of this embodiment is to be compatible with the miswriting of the specified attribute value carried by the attribute configuration instruction. For example, if DEBUG is mistakenly written as DEBAG, the similarity algorithm according to this embodiment will determine that the two are the same, so there is no need to update the attribute. This avoids the use of ordinary text comparison methods (comparing characters one by one, if there is a difference, the judgment is not the same) to judge the two as different, which will lead to the subsequent incorrect unrecognizable DEBAG (DEBUG is the log level, and DEBAG is not) Set to the attribute value of the log4j log frame, causing serious errors.
在一个实施方式中,所述相似程度值计算子单元,包括:In one embodiment, the similarity value calculation subunit includes:
相似程度值计算模块,用于采用公式:Similarity value calculation module, used to adopt formula:
Figure PCTCN2019117667-appb-000002
Figure PCTCN2019117667-appb-000002
计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
如上所述,实现了采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值。所述字符频率向量是以所述指定系统变量或者所述指定属性值的各个字符出现的次数(频率)作为向量的维度数值,所构成的多维向量。即A=(A1,A2,…,An),其中An为最后一个字符(共有n个字符)出现的次数。所述相似度算法是根据所述指定系统变量与所述指定属性值的余弦相似度进行计算得到,以反应所述指定系统变量与所述指定属性值的相似程度。当similarity的值越接近于1,表明越相似;越接近于0,表明越不相似。As described above, it is realized that the preset similarity algorithm is used to calculate the similarity value between the designated system variable and the designated attribute value. The character frequency vector is a multidimensional vector formed by taking the number of times (frequency) of each character of the designated system variable or the designated attribute value as the dimensional value of the vector. That is, A=(A1,A2,...,An), where An is the number of times the last character (a total of n characters) appears. The similarity algorithm is calculated according to the cosine similarity between the designated system variable and the designated attribute value, so as to reflect the degree of similarity between the designated system variable and the designated attribute value. When the value of similarity is closer to 1, the more similar is; the closer to 0, the less similar.
在一个实施方式中,所述属性值编辑单元40,包括:In one embodiment, the attribute value editing unit 40 includes:
权限判断子单元,用于若所述指定系统变量与所述指定属性值不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;A permission judgment subunit, configured to judge whether the user account sending the attribute configuration instruction is in a preset permission user list if the specified system variable is not the same as the specified attribute value;
参数范围判断子单元,用于若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;The parameter range determination subunit is configured to determine whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account that sends the attribute configuration instruction is in the preset list of authorized users;
属性值编辑子单元,用于若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。The attribute value editing subunit is configured to, if the specified attribute value does not exceed the preset parameter range of the specified system variable, call a preset system variable editing method to edit the specified system variable to the specified attribute value.
如上所述,实现了在调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值之前,进行权限验证与参数验证。其中,预设的权限用户列表中的用户账户具有对系统变量进行编辑的权限,以减少系统变量被篡改的可能性。预设参数范围限定了所述指定系统变量能够被设置的参数内容,例如日志级别可被设置为五个级别:DEBUG、INFO、WARN、ERROR和FATAL,即预设参数范围为DEBUG、INFO、WARN、ERROR和FATAL。从而先进行权限验证与参数验证,以减少属性配置发生错误的可能性。As described above, before calling the preset system variable editing method to edit the designated system variable to the designated attribute value, authorization verification and parameter verification are implemented. Among them, the user accounts in the preset list of authorized users have the authority to edit system variables, so as to reduce the possibility of system variables being tampered with. The preset parameter range limits the parameter content that the specified system variable can be set. For example, the log level can be set to five levels: DEBUG, INFO, WARN, ERROR and FATAL, that is, the preset parameter range is DEBUG, INFO, WARN , ERROR and FATAL. Therefore, authorization verification and parameter verification are performed first to reduce the possibility of attribute configuration errors.
在一个实施方式中,所述属性值编辑单元40,包括:In one embodiment, the attribute value editing unit 40 includes:
提醒信息生成子单元,用于若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;The reminder information generating subunit is configured to generate reminder information of parameter errors if the specified attribute value exceeds the preset parameter range of the specified system variable;
提醒信息返回子单元,用于将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。The reminder information return subunit is used to return the reminder information of the parameter error to the terminal that sends the attribute configuration instruction of the log4j log frame.
如上所述,实现了将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。若所述指定属性值超出所述指定系统变量的预设参数范围,则所述指定属性值不能进行配置,否则将导致log4j日志框架出错,例如日志级别的预设参数范围为DEBUG、INFO、WARN、ERROR和FATAL,而指定属性值为right,超出所述指定系统变量的预设参数范围,则应生成参数错误的提醒信息,将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。As described above, it is realized that the reminder information of the parameter error is returned to the terminal that sends the attribute configuration instruction of the log4j log framework. If the specified attribute value exceeds the preset parameter range of the specified system variable, the specified attribute value cannot be configured, otherwise it will cause an error in the log4j log framework. For example, the preset parameter range of the log level is DEBUG, INFO, WARN , ERROR and FATAL, and the specified attribute value is right, which exceeds the preset parameter range of the specified system variable, a warning message of parameter error should be generated, and the warning message of the parameter error should be returned to the sender of the log4j log frame The terminal of the attribute configuration command.
在一个实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述更新单元50,包括:In one embodiment, the attributes other than the specified attributes in the configuration file record preset attribute values, and the updating unit 50 includes:
加载方法调用子单元,用于调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;The loading method calling subunit is used to call a preset configuration file loading method, and according to the configuration file, update the specified attribute of the log4j log frame to the specified attribute value;
其他属性的值保留子单元,用于将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。The value retention sub-unit of other attributes is used to retain the values of the other attributes except the specified attributes, so as to complete the attribute configuration of the log4j log framework.
如上所述,实现了完成所述log4j日志框架的属性配置。本实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,因此在进行属性配置(属性更新)时无需更新所述其他属性(因此配置文件未修改,因此其他属性不可能发生改变),从而减少了计算量,提高了属性配置速度。据此,仅将所述log4j日志框架的指定属性更新为所述指定属性值,将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。As mentioned above, the property configuration of the log4j log framework is completed. In this embodiment, other attributes in the configuration file other than the specified attribute record the preset attribute value, so there is no need to update the other attributes when performing attribute configuration (attribute update) (so the configuration file is not modified, so It is impossible to change other attributes), which reduces the amount of calculation and improves the speed of attribute configuration. Accordingly, only the designated attribute of the log4j log framework is updated to the designated attribute value, and the values of the other attributes except the designated attribute are retained, thereby completing the attribute configuration of the log4j log framework.
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储log4j日志框架的属性配置方法所用数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种log4j日志框架的属性配置方法。3, an embodiment of the present application also provides a computer device. The computer device may be a server, and its internal structure may be as shown in the figure. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer readable instructions, and a database. The memory provides an environment for the operation of the operating system and computer readable instructions in the non-volatile storage medium. The database of the computer equipment is used to store the data used in the attribute configuration method of the log4j log framework. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instruction is executed by the processor, a method for configuring attributes of the log4j logging framework is realized.
上述处理器执行上述log4j日志框架的属性配置方法,包括以下步骤:接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。The processor executes the attribute configuration method of the log4j log framework, including the following steps: receiving an attribute configuration instruction for the log4j log framework, the attribute configuration instruction carrying a specified attribute value; according to the attribute configuration instruction, calling a preset A configuration file, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to a special symbol representing a designated system variable; the designated system variable placeholder is used Obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value; if the designated system variable is not the same as the designated attribute value, call the preset system variable editing method to change the The specified system variable is edited as the specified attribute value; the preset configuration file loading method is called, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the log4j log The attribute configuration of the framework.
在一个实施方式中,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤之前,包括:统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;将所述配置文件中的待修改属性的位置设置系统变量占位符。In one embodiment, the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies The position symbol refers to the special symbol representing the designated system variable before the step, including: counting the number of times the attribute of the log4j log frame has been modified within a predetermined time, and recording the attribute whose number of times of modification exceeds the preset number threshold as the attribute to be modified; Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
在一个实施方式中,所述利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤,包括:根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。In one embodiment, the step of obtaining the designated system variable by using the designated system variable placeholder and determining whether the designated system variable is the same as the designated attribute value includes: according to a preset system variable The corresponding relationship between the placeholder and the system variable, using the designated system variable placeholder to obtain the designated system variable; using a preset similarity algorithm to calculate the similarity value between the designated system variable and the designated attribute value; If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
在一个实施方式中,所述采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值的步骤,包括:采用公式:In one embodiment, the step of calculating the similarity value between the specified system variable and the specified attribute value by using a preset similarity algorithm includes: using a formula:
Figure PCTCN2019117667-appb-000003
Figure PCTCN2019117667-appb-000003
计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
在一个实施方式中,所述若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值的步骤,包括:若所述指定系统变量与所述指定属性值不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。In one embodiment, the step of calling a preset system variable editing method to edit the designated system variable to the designated attribute value if the designated system variable is different from the designated attribute value includes: If the specified system variable is not the same as the specified attribute value, it is determined whether the user account that sends the attribute configuration instruction is in the preset list of authorized users; if the user account that sends the attribute configuration instruction is in the preset In the list of authorized users, determine whether the specified attribute value exceeds the preset parameter range of the specified system variable; if the specified attribute value does not exceed the preset parameter range of the specified system variable, call the preset system The variable editing method edits the designated system variable to the designated attribute value.
在一个实施方式中,所述若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围的步骤之后,包括:若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。In one embodiment, after the step of judging whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account sending the attribute configuration instruction is in a preset list of authorized users, Including: if the specified attribute value exceeds the preset parameter range of the specified system variable, generating a parameter error reminder message; returning the parameter error reminder message to the terminal that sent the log4j log frame attribute configuration instruction .
在一个实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置的步骤,包括:调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;将所述除指定属性之外的其他属性 的值保留,从而完成所述log4j日志框架的属性配置。In one embodiment, the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file The step of updating the current attribute value to the specified attribute value to complete the attribute configuration of the log4j log framework includes: calling a preset configuration file loading method, and assigning the log4j log framework to the specified configuration file according to the configuration file The attribute is updated to the specified attribute value; the values of the other attributes except the specified attribute are retained, thereby completing the attribute configuration of the log4j log framework.
本领域技术人员可以理解,图中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。Those skilled in the art can understand that the structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
本申请一实施例还提供一种计算机可读存储介质,其上存储有计算机可读指令,计算机可读指令被处理器执行时实现log4j日志框架的属性配置方法,包括以下步骤:接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。所述计算机可读存储介质,例如为非易失性的计算机可读存储介质,或者为易失性的计算机可读存储介质。An embodiment of the present application also provides a computer-readable storage medium on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, a method for configuring attributes of the log4j log framework is implemented, including the following steps: receiving log4j logs The attribute configuration instruction of the framework, the attribute configuration instruction carries a specified attribute value; according to the attribute configuration instruction, a preset configuration file is called, wherein a specified system variable is set in the position of the specified attribute in the configuration file The designated system variable placeholder refers to a special symbol representing a designated system variable; the designated system variable placeholder is used to obtain the designated system variable, and it is judged whether the designated system variable is the same as the designated attribute value The same; if the specified system variable is not the same as the specified attribute value, call the preset system variable editing method to edit the specified system variable to the specified attribute value; call the preset configuration file loading method to Make the log4j log framework update the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework. The computer-readable storage medium is, for example, a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
在一个实施方式中,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤之前,包括:统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;将所述配置文件中的待修改属性的位置设置系统变量占位符。In one embodiment, the preset configuration file is called according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies The position symbol refers to the special symbol representing the designated system variable before the step, including: counting the number of times the attribute of the log4j log frame has been modified within a predetermined time, and recording the attribute whose number of times of modification exceeds the preset number threshold as the attribute to be modified; Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
在一个实施方式中,所述利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤,包括:根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。In one embodiment, the step of obtaining the designated system variable by using the designated system variable placeholder and determining whether the designated system variable is the same as the designated attribute value includes: according to a preset system variable The corresponding relationship between the placeholder and the system variable, using the designated system variable placeholder to obtain the designated system variable; using a preset similarity algorithm to calculate the similarity value between the designated system variable and the designated attribute value; If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
在一个实施方式中,所述采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值的步骤,包括:采用公式:In one embodiment, the step of calculating the similarity value between the specified system variable and the specified attribute value by using a preset similarity algorithm includes: using a formula:
Figure PCTCN2019117667-appb-000004
Figure PCTCN2019117667-appb-000004
计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
在一个实施方式中,所述若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值的步骤,包括:若所述指定系统变量与所述指定属性值 不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。In one embodiment, the step of calling a preset system variable editing method to edit the designated system variable to the designated attribute value if the designated system variable is different from the designated attribute value includes: If the specified system variable is not the same as the specified attribute value, it is determined whether the user account that sends the attribute configuration instruction is in the preset list of authorized users; if the user account that sends the attribute configuration instruction is in the preset In the list of authorized users, determine whether the specified attribute value exceeds the preset parameter range of the specified system variable; if the specified attribute value does not exceed the preset parameter range of the specified system variable, call the preset system The variable editing method edits the designated system variable to the designated attribute value.
在一个实施方式中,所述若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围的步骤之后,包括:若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。In one embodiment, after the step of judging whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account sending the attribute configuration instruction is in a preset list of authorized users, Including: if the specified attribute value exceeds the preset parameter range of the specified system variable, generating a parameter error reminder message; returning the parameter error reminder message to the terminal that sent the log4j log frame attribute configuration instruction .
在一个实施方式中,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置的步骤,包括:调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。In one embodiment, the attributes other than the specified attributes in the configuration file record preset attribute values, and the preset configuration file loading method is invoked, so that the log4j log framework is based on the configuration file The step of updating the current attribute value to the specified attribute value to complete the attribute configuration of the log4j log framework includes: calling a preset configuration file loading method, and assigning the log4j log framework to the specified configuration file according to the configuration file The attribute is updated to the specified attribute value; the values of the other attributes except the specified attribute are retained, thereby completing the attribute configuration of the log4j log framework.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的和实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可以包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双速据率SDRAM(SSRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through computer-readable instructions, which can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。It should be noted that in this article, the terms "including", "including" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements not only includes those elements, It also includes other elements that are not explicitly listed, or elements inherent to the process, device, article, or method. Without more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, device, article, or method that includes the element.

Claims (20)

  1. 一种log4j日志框架的属性配置方法,其特征在于,包括:A method for configuring attributes of log4j log framework, which is characterized in that it includes:
    接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;Receiving an attribute configuration instruction to the log4j log framework, where the attribute configuration instruction carries a specified attribute value;
    根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;According to the attribute configuration instruction, a preset configuration file is retrieved, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to the designated system variable Special symbol
    利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;Using the designated system variable placeholder to obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value;
    若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;If the designated system variable is not the same as the designated attribute value, calling a preset system variable editing method to edit the designated system variable to the designated attribute value;
    调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。Calling a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  2. 根据权利要求1所述的log4j日志框架的属性配置方法,其特征在于,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤之前,包括:The log4j log framework attribute configuration method according to claim 1, characterized in that, according to the attribute configuration instruction, a preset configuration file is called, wherein the position of the specified attribute in the configuration file is set with The designated system variable placeholder, the designated system variable placeholder refers to the special symbol representing the designated system variable before the step, includes:
    统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;Collect statistics on the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record the attributes whose number of times have been modified over a preset number threshold as attributes to be modified;
    将所述配置文件中的待修改属性的位置设置系统变量占位符。Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
  3. 根据权利要求1所述的log4j日志框架的属性配置方法,其特征在于,所述利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤,包括:根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;The log4j log framework attribute configuration method according to claim 1, wherein the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute. The step of having the same value includes: obtaining the designated system variable by using the designated system variable placeholder according to the corresponding relationship between the preset system variable placeholder and the system variable;
    采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;Using a preset similarity algorithm to calculate a similarity value between the designated system variable and the designated attribute value;
    若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
  4. 根据权利要求3所述的log4j日志框架的属性配置方法,其特征在于,所述采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值的步骤,包括:The log4j log framework attribute configuration method according to claim 3, wherein the step of calculating the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm comprises:
    采用公式:Use the formula:
    Figure PCTCN2019117667-appb-100001
    Figure PCTCN2019117667-appb-100001
    计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个 字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
  5. 根据权利要求1所述的log4j日志框架的属性配置方法,其特征在于,所述若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值的步骤,包括:The log4j log framework attribute configuration method according to claim 1, wherein if the specified system variable is not the same as the specified attribute value, then a preset system variable editing method is called to modify the specified system The step of editing the variable as the specified attribute value includes:
    若所述指定系统变量与所述指定属性值不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;If the specified system variable is not the same as the specified attribute value, determining whether the user account that sends the attribute configuration instruction is in a preset list of authorized users;
    若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;If the user account sending the attribute configuration instruction is in the preset list of authorized users, determining whether the specified attribute value exceeds the preset parameter range of the specified system variable;
    若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。If the specified attribute value does not exceed the preset parameter range of the specified system variable, a preset system variable editing method is called to edit the specified system variable to the specified attribute value.
  6. 根据权利要求5所述的log4j日志框架的属性配置方法,其特征在于,所述若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围的步骤之后,包括:The log4j log framework attribute configuration method according to claim 5, wherein if the user account sending the attribute configuration instruction is in a preset list of authorized users, it is determined whether the specified attribute value exceeds all After describing the steps of specifying the preset parameter range of system variables, include:
    若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;If the specified attribute value exceeds the preset parameter range of the specified system variable, generating a parameter error warning message;
    将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。The reminder message of the parameter error is returned to the terminal that sent the attribute configuration instruction of the log4j log frame.
  7. 根据权利要求1所述的log4j日志框架的属性配置方法,其特征在于,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置的步骤,包括:The attribute configuration method of the log4j log framework according to claim 1, wherein other attributes in the configuration file except the specified attribute record the preset attribute value, and the preset configuration file loading method is called , So that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the step of configuring the attributes of the log4j log framework, including:
    调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;Call a preset configuration file loading method, and update the specified attribute of the log4j log frame to the specified attribute value according to the configuration file;
    将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。The values of the attributes other than the specified attributes are retained, thereby completing the attribute configuration of the log4j logging framework.
  8. 一种log4j日志框架的属性配置装置,其特征在于,包括:An attribute configuration device of log4j log framework, characterized in that it comprises:
    属性配置指令接收单元,用于接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;The attribute configuration instruction receiving unit is configured to receive an attribute configuration instruction to the log4j log framework, and the attribute configuration instruction carries a specified attribute value;
    配置文件调取单元,用于根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;The configuration file retrieval unit is configured to retrieve a preset configuration file according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file, and the designated system variable occupies Bit symbol refers to the special symbol that represents the specified system variable;
    指定属性值判断单元,用于利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;The designated attribute value judgment unit is configured to obtain the designated system variable by using the designated system variable placeholder, and determine whether the designated system variable is the same as the designated attribute value;
    属性值编辑单元,用于若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;The attribute value editing unit is configured to, if the designated system variable is not the same as the designated attribute value, call a preset system variable editing method to edit the designated system variable to the designated attribute value;
    更新单元,用于调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。The update unit is configured to call a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  9. 根据权利要求8所述的log4j日志框架的属性配置装置,其特征在于,所述装置,包括:The device for configuring attributes of the log4j log framework according to claim 8, wherein the device comprises:
    待修改属性标记单元,用于统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;The attribute to be modified marking unit is used to count information about the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record attributes whose number of times of modification exceeds a preset number threshold as attributes to be modified;
    系统变量占位符设置单元,用于将所述配置文件中的待修改属性的位置设置系统变量占位符。The system variable placeholder setting unit is used to set the system variable placeholder in the position of the attribute to be modified in the configuration file.
  10. 根据权利要求8所述的log4j日志框架的属性配置装置,其特征在于,所述指定属性值判断单元,包括:The log4j log framework attribute configuration device according to claim 8, wherein the designated attribute value judgment unit comprises:
    指定系统变量获取子单元,用于根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;The designated system variable obtaining subunit is configured to obtain the designated system variable by using the designated system variable placeholder according to the corresponding relationship between the preset system variable placeholder and the system variable;
    相似程度值计算子单元,用于采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;The similarity value calculation subunit is used to calculate the similarity value between the designated system variable and the designated attribute value by using a preset similarity algorithm;
    不相同判定子单元,用于若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。The dissimilar determination subunit is configured to determine that the specified system variable is not the same as the specified attribute value if the similarity value is less than a preset similarity threshold.
  11. 根据权利要求10所述的log4j日志框架的属性配置装置,其特征在于,所述相似程度值计算子单元,包括:The attribute configuration device of the log4j log framework according to claim 10, wherein the similarity value calculation subunit comprises:
    相似程度值计算模块,用于采用公式:Similarity value calculation module, used to adopt formula:
    Figure PCTCN2019117667-appb-100002
    Figure PCTCN2019117667-appb-100002
    计算出所述指定系统变量与所述指定属性值的相似程度值;其中similarity为相似程度值,A为所述指定系统变量的字符频率向量,B为所述指定属性值的字符频率向量,Ai为所述指定系统变量的第i个字符出现的次数,Bi为所述指定属性值的第i个字符出现的次数。Calculate the similarity value between the designated system variable and the designated attribute value; where similarity is the similarity value, A is the character frequency vector of the designated system variable, B is the character frequency vector of the designated attribute value, Ai Is the number of occurrences of the i-th character of the designated system variable, and Bi is the number of occurrences of the i-th character of the designated attribute value.
  12. 根据权利要求8所述的log4j日志框架的属性配置装置,其特征在于,所述属性值编辑单元,包括:The log4j log framework attribute configuration device according to claim 8, wherein the attribute value editing unit comprises:
    权限判断子单元,用于若所述指定系统变量与所述指定属性值不相同,则判断发送所述属性配置指令的用户账户是否处于预设的权限用户列表中;A permission judgment subunit, configured to judge whether the user account sending the attribute configuration instruction is in a preset permission user list if the specified system variable is not the same as the specified attribute value;
    参数范围判断子单元,用于若发送所述属性配置指令的用户账户处于预设的权限用户列表中,则判断所述指定属性值是否超出所述指定系统变量的预设参数范围;The parameter range determination subunit is configured to determine whether the specified attribute value exceeds the preset parameter range of the specified system variable if the user account that sends the attribute configuration instruction is in the preset list of authorized users;
    属性值编辑子单元,用于若所述指定属性值未超出所述指定系统变量的预设参数范围,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值。The attribute value editing subunit is configured to, if the specified attribute value does not exceed the preset parameter range of the specified system variable, call a preset system variable editing method to edit the specified system variable to the specified attribute value.
  13. 根据权利要求12所述的log4j日志框架的属性配置装置,其特征在于,所述属性值编辑单元,包括:The attribute configuration device of the log4j log framework according to claim 12, wherein the attribute value editing unit comprises:
    提醒信息生成子单元,用于若所述指定属性值超出所述指定系统变量的预设参数范围,则生成参数错误的提醒信息;The reminder information generating subunit is configured to generate reminder information of parameter errors if the specified attribute value exceeds the preset parameter range of the specified system variable;
    提醒信息返回子单元,用于将所述参数错误的提醒信息返回给发送所述log4j日志框架的属性配置指令的终端。The reminder information return subunit is used to return the reminder information of the parameter error to the terminal that sends the attribute configuration instruction of the log4j log frame.
  14. 根据权利要求8所述的log4j日志框架的属性配置装置,其特征在于,所述配置文件中的除指定属性之外的其他属性记载了预设属性值,所述更新单元,包括:The log4j log framework attribute configuration device according to claim 8, wherein other attributes in the configuration file except the specified attribute record the preset attribute value, and the update unit includes:
    加载方法调用子单元,用于调用预设的配置文件加载方法,依据所述配置文件,将所述log4j日志框架的指定属性更新为所述指定属性值;The loading method calling subunit is used to call a preset configuration file loading method, and according to the configuration file, update the specified attribute of the log4j log frame to the specified attribute value;
    其他属性的值保留子单元,用于将所述除指定属性之外的其他属性的值保留,从而完成所述log4j日志框架的属性配置。The value retention sub-unit of other attributes is used to retain the values of the other attributes except the specified attributes, so as to complete the attribute configuration of the log4j log framework.
  15. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现log4j日志框架的属性配置方法,所述log4j日志框架的属性配置方法,包括:A computer device includes a memory and a processor, the memory stores computer-readable instructions, and is characterized in that when the processor executes the computer-readable instructions, a method for configuring attributes of a log4j log framework is implemented, and the log4j log The attributes configuration methods of the framework include:
    接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;Receiving an attribute configuration instruction to the log4j log framework, where the attribute configuration instruction carries a specified attribute value;
    根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;According to the attribute configuration instruction, a preset configuration file is retrieved, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to the designated system variable Special symbol
    利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;Using the designated system variable placeholder to obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value;
    若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;If the designated system variable is not the same as the designated attribute value, calling a preset system variable editing method to edit the designated system variable to the designated attribute value;
    调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。Calling a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  16. 根据权利要求15所述的计算机设备,其特征在于,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤之前,包括:The computer device according to claim 15, wherein the preset configuration file is retrieved according to the attribute configuration instruction, wherein a designated system variable placeholder is set in the position of the designated attribute in the configuration file Before the step of the designated system variable placeholder refers to the special symbol representing the designated system variable, it includes:
    统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;Collect statistics on the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record the attributes whose number of times have been modified over a preset number threshold as attributes to be modified;
    将所述配置文件中的待修改属性的位置设置系统变量占位符。Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
  17. 根据权利要求15所述的计算机设备,其特征在于,所述利用所述指定系统变量占位符获取所 述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤,包括:15. The computer device according to claim 15, wherein the step of obtaining the designated system variable using the designated system variable placeholder, and determining whether the designated system variable is the same as the designated attribute value, include:
    根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;Obtaining the designated system variable by using the designated system variable placeholder according to the preset correspondence between the system variable placeholder and the system variable;
    采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;Using a preset similarity algorithm to calculate a similarity value between the designated system variable and the designated attribute value;
    若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
  18. 一种计算机可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现log4j日志框架的属性配置方法,所述log4j日志框架的属性配置方法,包括:A computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions are executed by a processor to implement an attribute configuration method of the log4j log framework, and the attribute configuration method of the log4j log framework ,include:
    接收对log4j日志框架的属性配置指令,所述属性配置指令携带有指定属性值;Receiving an attribute configuration instruction to the log4j log framework, where the attribute configuration instruction carries a specified attribute value;
    根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号;According to the attribute configuration instruction, a preset configuration file is retrieved, wherein a designated system variable placeholder is set at the position of the designated attribute in the configuration file, and the designated system variable placeholder refers to the designated system variable Special symbol
    利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同;Using the designated system variable placeholder to obtain the designated system variable, and determine whether the designated system variable is the same as the designated attribute value;
    若所述指定系统变量与所述指定属性值不相同,则调用预设的系统变量编辑方法将所述指定系统变量编辑为所述指定属性值;If the designated system variable is not the same as the designated attribute value, calling a preset system variable editing method to edit the designated system variable to the designated attribute value;
    调用预设的配置文件加载方法,以使所述log4j日志框架依据所述配置文件将当前属性值更新为所述指定属性值,从而完成所述log4j日志框架的属性配置。Calling a preset configuration file loading method, so that the log4j log framework updates the current attribute value to the specified attribute value according to the configuration file, thereby completing the attribute configuration of the log4j log framework.
  19. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述根据所述属性配置指令,调取预设的配置文件,其中所述配置文件中的指定属性的位置上设置有指定系统变量占位符,所述指定系统变量占位符指代表指定系统变量的特殊符号的步骤之前,包括:The computer-readable storage medium according to claim 18, wherein the configuration file is retrieved according to the attribute configuration instruction, wherein a designated system is set in the position of the designated attribute in the configuration file A variable placeholder, where the designated system variable placeholder refers to a special symbol representing a designated system variable before the step, including:
    统计预定时间内所述log4j日志框架的属性被修改次数信息,并将被修改次数超过预设数量阈值的属性记为待修改属性;Collect statistics on the number of times that the attributes of the log4j log frame have been modified within a predetermined time, and record the attributes whose number of times have been modified over a preset number threshold as attributes to be modified;
    将所述配置文件中的待修改属性的位置设置系统变量占位符。Set the position of the attribute to be modified in the configuration file as a system variable placeholder.
  20. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述利用所述指定系统变量占位符获取所述指定系统变量,并判断所述指定系统变量是否与所述指定属性值相同的步骤,包括:The computer-readable storage medium according to claim 18, wherein the designated system variable is obtained by using the designated system variable placeholder, and it is determined whether the designated system variable is the same as the designated attribute value The steps include:
    根据预设的系统变量占位符与系统变量的对应关系,利用所述指定系统变量占位符获取所述指定系统变量;Obtaining the specified system variable by using the specified system variable placeholder according to the preset correspondence between the system variable placeholder and the system variable;
    采用预设的相似度算法计算所述指定系统变量与所述指定属性值的相似程度值;Using a preset similarity algorithm to calculate a similarity value between the designated system variable and the designated attribute value;
    若所述相似程度值小于预设的相似度阈值,则判定所述指定系统变量与所述指定属性值不相同。If the similarity value is less than a preset similarity threshold, it is determined that the specified system variable is different from the specified attribute value.
PCT/CN2019/117667 2019-05-30 2019-11-12 Attribute configuration method and apparatus for log4j log framework, and computer device WO2020238049A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910463642.8 2019-05-30
CN201910463642.8A CN110334071A (en) 2019-05-30 2019-05-30 Attribute configuration method, device and the computer equipment of log4j log frame

Publications (1)

Publication Number Publication Date
WO2020238049A1 true WO2020238049A1 (en) 2020-12-03

Family

ID=68140557

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117667 WO2020238049A1 (en) 2019-05-30 2019-11-12 Attribute configuration method and apparatus for log4j log framework, and computer device

Country Status (2)

Country Link
CN (1) CN110334071A (en)
WO (1) WO2020238049A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110334071A (en) * 2019-05-30 2019-10-15 平安科技(深圳)有限公司 Attribute configuration method, device and the computer equipment of log4j log frame
US11449411B2 (en) 2020-06-02 2022-09-20 Red Hat, Inc. Application-specific log routing

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120215907A1 (en) * 2011-02-22 2012-08-23 Intuit Inc. Systems and methods for self-adjusting logging of log messages
CN105843822A (en) * 2015-01-16 2016-08-10 北京神州泰岳软件股份有限公司 Method and device for changing log levels
CN106681891A (en) * 2015-11-05 2017-05-17 阿里巴巴集团控股有限公司 Method and device for adjusting log levels in Java application system
CN106802858A (en) * 2017-01-16 2017-06-06 广东欧珀移动通信有限公司 A kind of daily record Dynamic Configuration, apparatus and system
CN108897659A (en) * 2018-06-06 2018-11-27 腾讯音乐娱乐科技(深圳)有限公司 Modify journal stage method for distinguishing, device and storage medium
CN110334071A (en) * 2019-05-30 2019-10-15 平安科技(深圳)有限公司 Attribute configuration method, device and the computer equipment of log4j log frame

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7716017B2 (en) * 2002-08-16 2010-05-11 Oracle America, Inc. Distributed plug-and-play logging services
US7412691B2 (en) * 2004-12-27 2008-08-12 International Business Machines Corporation Dynamic configuration files
US8700414B2 (en) * 2004-12-29 2014-04-15 Sap Ag System supported optimization of event resolution
US8694834B2 (en) * 2010-11-30 2014-04-08 International Business Machines Corporation Preventing log wrap with debug scripts
US10585908B2 (en) * 2015-04-03 2020-03-10 Oracle International Corporation Method and system for parameterizing log file location assignments for a log analytics system
US9934303B2 (en) * 2016-04-25 2018-04-03 Dropbox, Inc. Storage constrained synchronization engine

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120215907A1 (en) * 2011-02-22 2012-08-23 Intuit Inc. Systems and methods for self-adjusting logging of log messages
CN105843822A (en) * 2015-01-16 2016-08-10 北京神州泰岳软件股份有限公司 Method and device for changing log levels
CN106681891A (en) * 2015-11-05 2017-05-17 阿里巴巴集团控股有限公司 Method and device for adjusting log levels in Java application system
CN106802858A (en) * 2017-01-16 2017-06-06 广东欧珀移动通信有限公司 A kind of daily record Dynamic Configuration, apparatus and system
CN108897659A (en) * 2018-06-06 2018-11-27 腾讯音乐娱乐科技(深圳)有限公司 Modify journal stage method for distinguishing, device and storage medium
CN110334071A (en) * 2019-05-30 2019-10-15 平安科技(深圳)有限公司 Attribute configuration method, device and the computer equipment of log4j log frame

Also Published As

Publication number Publication date
CN110334071A (en) 2019-10-15

Similar Documents

Publication Publication Date Title
CN109446068B (en) Interface test method, device, computer equipment and storage medium
CN112181945B (en) Data archiving processing method, device, computer equipment and storage medium
CN109308285A (en) Database script management method, device, computer equipment and storage medium
WO2020238049A1 (en) Attribute configuration method and apparatus for log4j log framework, and computer device
CN112613993B (en) Transaction data processing method and device, computer equipment and storage medium
WO2019144548A1 (en) Security test method, apparatus, computer device and storage medium
WO2020232883A1 (en) Script defect scanning method and apparatus, computer device and storage medium
WO2021066954A1 (en) Subscription to dependencies in smart contracts
WO2021174817A1 (en) Database automated auditing method and system, device, and storage medium
CN111488736B (en) Self-learning word segmentation method, device, computer equipment and storage medium
CN114385760A (en) Method and device for real-time synchronization of incremental data, computer equipment and storage medium
US20150020167A1 (en) System and method for managing files
WO2020211233A1 (en) Method and device for batch data editing, computer device, and storage medium
CN110941543A (en) Log processing method and device, computer equipment and storage medium
CN111444208B (en) Data updating method and related equipment
CN112130759A (en) Parameter configuration method, system and related device of storage system
WO2020253044A1 (en) Service configuration method and apparatus, and computer device and storage medium
CN115039082A (en) Log writing method and device, electronic equipment and storage medium
US11941032B2 (en) Key name generation method and apparatus and non-transitory computer-readable storage medium
CN110321711A (en) Detect the method and system of application server SQL injection point
CN115391188A (en) Scene test case generation method, device, equipment and storage medium
CN112528334B (en) Data acquisition method and device based on blockchain network and computer equipment
CN115827691A (en) Batch processing result verification method and device, computer equipment and storage medium
CN111258871B (en) Verification method, device, equipment and storage medium of distributed file system
CN111258877B (en) Method and device for detecting visible time of first screen page and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19930889

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19930889

Country of ref document: EP

Kind code of ref document: A1