[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN117539840B - Log acquisition method, device, equipment and medium - Google Patents

Log acquisition method, device, equipment and medium Download PDF

Info

Publication number
CN117539840B
CN117539840B CN202410033266.XA CN202410033266A CN117539840B CN 117539840 B CN117539840 B CN 117539840B CN 202410033266 A CN202410033266 A CN 202410033266A CN 117539840 B CN117539840 B CN 117539840B
Authority
CN
China
Prior art keywords
log
target
key value
mark key
service
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202410033266.XA
Other languages
Chinese (zh)
Other versions
CN117539840A (en
Inventor
马文哲
韩爱生
金华利
王燕灵
丁乔
胡泰嵩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou New China And Big Polytron Technologies Inc
Original Assignee
Hangzhou New China And Big Polytron Technologies Inc
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 Hangzhou New China And Big Polytron Technologies Inc filed Critical Hangzhou New China And Big Polytron Technologies Inc
Priority to CN202410033266.XA priority Critical patent/CN117539840B/en
Publication of CN117539840A publication Critical patent/CN117539840A/en
Application granted granted Critical
Publication of CN117539840B publication Critical patent/CN117539840B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1273Print job history, e.g. logging, accounting, tracking
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a log acquisition method, a log acquisition device, log acquisition equipment and a log acquisition medium. The method comprises the following steps: when detecting the service call requirement of the target interface, respectively establishing a mark key value pair for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface; storing each flag key value in the matched target thread respectively; executing log printing actions in parallel through each target thread, and generating and outputting a printing log; and collecting each print log at the matched storage position according to the mark key value pair corresponding to the output thread of each print log. By the technical scheme, the method and the device for generating and outputting the printing logs can generate and output the printing logs matched with the service call requirements when the service call requirements of the target interface are detected, so that the log acquisition efficiency is improved, the real-time collection of the output logs when the target interface is called by the service call requirements is realized, and the flexibility of the service end in using the logs is improved.

Description

Log acquisition method, device, equipment and medium
Technical Field
The present invention relates to the field of data processing, and in particular, to a method, an apparatus, a device, and a medium for acquiring logs.
Background
The intelligent electronic equipment, such as a mobile phone, a tablet personal computer and the like, is provided with a log file capable of recording the operation of the system, and a system developer of the intelligent electronic equipment can know the problems in the operation process of the intelligent electronic equipment through the log file so as to be beneficial to after-sales service and subsequent system improvement.
The conventional method for collecting logs generated by the server application is to collect all logs generated by the server application in a hard disk in a whole log file set or time-slicing collection mode without distinguishing or classifying during the period from application starting to application closing.
The conventional log collection method has the following problems: on the one hand, the server side is difficult to acquire the log generated by the server side, particularly the log generated by a certain method when being called for a certain time, so that the user cannot flexibly use the output log; on the other hand, the logs are collected in the hard disk in a mode of whole log file collection or time slicing collection, so that when the related staff extracts the target logs, effective log information can be formed by analyzing, classifying and screening line by line after all log files are read from the hard disk, and further the target logs required by the related staff are obtained, and the obtaining efficiency of the target logs is reduced. In summary, the existing log obtaining method has low log obtaining efficiency, and has no real-time property, and meanwhile, the log is collected by the log collecting method in the conventional manner, so that the log is difficult to flexibly use.
Disclosure of Invention
The invention provides a log obtaining method, a device, equipment and a medium, which can solve the problem that the prior art cannot search and print specific logs in a high concurrency environment.
In a first aspect, an embodiment of the present invention provides a log obtaining method, where the method includes:
When detecting the service call requirement of the target interface, respectively establishing a mark key value pair for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface;
Storing each mark key value in a matched target thread respectively, wherein different target threads have the same mark key name and different mark key values;
executing log printing actions in parallel through each target thread, and generating and outputting a printing log;
And collecting each print log at the matched storage position according to the mark key value pair corresponding to the output thread of each print log.
In a second aspect, an embodiment of the present invention provides a log obtaining apparatus, including:
The mark key value pair establishing module is used for respectively establishing mark key value pairs for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface when the service calling requirement of the target interface is detected;
The storage module of the sign key value pair is used for storing each sign key value pair into a matched target thread, wherein different target threads have the same sign key name and different sign key values;
The printing log output module is used for executing log printing actions in parallel through each target thread, and generating and outputting a printing log;
And the printing log collecting module is used for collecting the printing logs at the matched storage positions according to the mark key value pairs respectively corresponding to the output threads of the printing logs.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform a log obtaining method according to any one of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, where computer instructions are stored, where the computer instructions are configured to cause a processor to execute a log obtaining method according to any one of the embodiments of the present invention.
According to the technical scheme, when the service call requirement of the target interface is detected, the mark key value pairs are respectively built for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface, then each mark key value pair is respectively stored in the matched target thread, log printing actions are executed in parallel through each target thread to generate and output the printing logs, and finally each printing log is collected to the matched storage position according to the mark key value pairs respectively corresponding to the output threads of each printing log, so that the generation and output of the printing logs matched with the service call requirement when the service call requirement of the target interface is detected can be realized, the log acquisition efficiency is improved, the real-time collection of the logs output when the target interface is called by the service call requirement is realized, and the use flexibility of the service end to the logs is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a log obtaining method according to a first embodiment of the present invention;
fig. 2 is a flowchart of a log obtaining method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a log obtaining device according to a third embodiment of the present invention;
Fig. 4 is a schematic structural diagram of an electronic device implementing a log obtaining method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a log obtaining method according to a first embodiment of the present invention, where the method may be performed by a log obtaining device, and the log obtaining device may be implemented in hardware and/or software, and the log obtaining device may be configured in a terminal or a server with a log obtaining function.
As shown in fig. 1, the method includes:
S110, when detecting the service call requirement of the target interface, respectively establishing a mark key value pair for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface.
In this embodiment, the service call requirement may be generated by a related person based on a related operation of the server; further, in this embodiment, the number of the detected service call requirements may be one or more, and simultaneously, the number of the detected service call requirements may correspond to one or more target interfaces at the same time, and the number of specific service call requirements and the number of target interfaces may be determined according to the actual working requirements of related personnel, which is not limited in this embodiment.
Further, when detecting a service call requirement for a target interface, the server detects a service requirement type of the service call requirement, namely, judges a function type required to be completed by the current service call requirement; further, in this embodiment, the service requirement types include, but are not limited to: generating reports, data queries, data modifications, etc.; for example, if the service requirement type of the service call requirement is a report, the log generated by the target interface in the report generation process is required to be acquired by the relevant user through the service call requirement.
In a specific implementation manner of this embodiment, according to a service requirement type and an interface name of a target interface, a flag key value pair is respectively established for each target thread included in the target interface, and if it is detected that the service requirement type of the current service call requirement is a generation report and the interface name of the target interface is "interface a", it may be determined that the flag key value pair established by the target thread is "interface a+generation report ID" according to a preset name generation rule and the interface name of the target interface; in the foregoing embodiment, the preset name generation rule is: when the current interface is identified as the report generation interface, the name of the generated report ID is used as the information of the flag key value pair to generate the flag key value pair, and it should be noted that in practical application, setting and adjustment of the name generation rule can be performed according to the actual needs or personal habits of related personnel, and the specific name generation rule is not required in this embodiment.
Optionally, the number of target threads should be equal to the number of detected service call requirements for the target interface.
S120, storing each flag key value in the matched target thread respectively.
Wherein different target threads have the same tag key name and different tag key values.
In this embodiment, specifically, on the basis of the foregoing steps, the name of the flag key of the target thread is generated based on the name of the target interface, and the value of the flag key is generated based on the service requirement type matched with the target thread; it is easy to understand that since each target thread originates from the same target interface, different target threads have the same tag key name, while different target threads match different service call requirements and thus have different tag key values.
S130, executing log printing actions in parallel through each target thread, and generating and outputting a printing log.
Wherein, the parallel refers to that a group of programs are executed at independent and asynchronous speeds, and the programs are executed together from microscopic or macroscopic; correspondingly, in this embodiment, the parallel execution log printing action is used as each target thread to print the log generated by itself at an independent asynchronous speed.
The print log is a log file output through log print actions executed by each target thread.
And S140, collecting each print log at a matched storage position according to the mark key value pair corresponding to the output thread of each print log.
In this embodiment, the method for collecting each print log at the matched storage position based on the flag key value pair of each output thread realizes the classified storage of the print logs, that is, the print logs matched with the same service call requirement are stored at the same storage position on the basis of the steps, realizes the automatic classification of each print log, solves the problem that the prior art can form effective log information only by reading all log files from a hard disk and then analyzing, classifying and screening line by line when acquiring the log, further acquires the target log required by related personnel, and improves the acquisition efficiency of the log.
Optionally, on the basis of the above steps, each print log is firstly collected into a memory, and finally the memory flows to a database for persistent storage, and when the query operation of the log is performed, if the queried target log exists in the memory, the queried target log is called from the memory as a query result; correspondingly, if the queried target log does not exist in the memory, searching the target log from the database, and taking the searched target log as a query result to ensure that the target log can be queried in real time.
Further, the method for searching the target log from the database may be: and determining a unique log corresponding to the mark key value in a log set of a database based on the mark key value pair corresponding to the target log, and outputting the unique log as the target log.
Note that, the print log collected by the log collection method provided by the present embodiment may implement persistence of the log according to the setting of the user.
That is, when the print log is stored in the memory, real-time log searching can be provided, and after log collection is finished, the corresponding inquiry capability can be provided for the user by performing persistent storage on the print log in the database.
Based on the steps, according to the mark key value pair corresponding to the output thread of each printing log, collecting each printing log to a matched storage position, including: acquiring a current printing log; if the output thread in the current printing log contains the current mark key value pair, identifying the current mark key name and the mark key value in the current mark key value pair; positioning a current primary grouping corresponding to the current mark key name in a set storage space, and positioning a current secondary grouping corresponding to the current mark key value in the current primary grouping; the current print log is stored in the current secondary packet.
For example, if the content of the flag key value pair included in the output thread of the current print log is "interface a+generate report ID", the current flag key name is identified as interface a, the flag key value is "generate report ID", then, in the set storage space, the primary packet named "interface a" is located, and the primary packet named "interface a" is summarized, the secondary packet named "generate report ID" is located, and finally, the current print log is stored in the secondary packet named "generate report ID".
In this embodiment, the set storage space is in a data structure with a data storage function in a current server memory; in this embodiment, since the storage space is set in the memory, the print logs can complete the read-write operation at the same time, that is, in practical application, it is not necessary to wait for the output thread to complete the output of all print logs and wait for all print logs to write into the storage space and then uniformly package all print logs so that related personnel can read the print logs, but in the process that the output thread continuously outputs each print log, the related personnel can sequentially read the print logs which are completed to the storage space by a single write, thereby saving the waiting time of the related personnel, avoiding the influence on the performance of the server application caused by a large amount of calculation force required by one-time reading of a large amount of log files, and reducing the performance loss of the log acquisition operation on the server application.
Further, after the current print log is obtained, the method further includes: and if the output thread of the current printing log does not contain the mark key value pair, discarding the execution of log storage operation on the current printing log.
In this embodiment, if the output thread of the current print log does not include the flag key value pair, it is indicated that the output thread of the current print log is not matched with any service call requirement, that is, the log printed by the output thread is not a requirement log of a related person, and log storage operation is abandoned for the current print log.
According to the technical scheme, when the service call requirement of the target interface is detected, the mark key value pairs are respectively built for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface, then each mark key value pair is respectively stored in the matched target thread, log printing actions are executed in parallel through each target thread to generate and output the printing logs, and finally each printing log is collected to the matched storage position according to the mark key value pairs respectively corresponding to the output threads of each printing log, so that the generation and output of the printing logs matched with the service call requirement when the service call requirement of the target interface is detected can be realized, the log acquisition efficiency is improved, the real-time collection of the logs output when the target interface is called by the service call requirement is realized, and the use flexibility of the service end to the logs is improved.
It should be noted again that: the log collector constructed by the log collecting method of the embodiments of the present invention has the following features:
1. In a single instance, logs with flag key value pairs are collected in groups after configuration; 2. the real-time reading and writing can collect concurrent logs and can also read specific logs from the concurrent logs in real time. (in particular, "copy-on-read" prevents complications); 3. a persistence interface is provided. Persistence to the specified location can be achieved by itself.
Example two
Fig. 2 is a flowchart of a log obtaining method according to a second embodiment of the present invention, where the method is based on the above embodiment, and specifically in this embodiment, when a service call requirement for a target interface is detected, a flag key value pair is respectively established for each target thread included in the target interface according to a service requirement type and an interface name of the target interface.
As shown in fig. 2, the method includes:
s210, when detecting the service call requirement of the target interface, generating each unique service ID matched with the service call requirement number according to the service requirement type of the target interface.
Specifically, when detecting a service call requirement for a target interface, generating each unique service ID matching the number of service call requirements according to the service requirement type of the target interface, including: when a plurality of concurrent requests initiated for the target interface are detected, generating unique service IDs respectively matched with each concurrent request according to the service demand type of the target interface.
Further, according to the service requirement type of the target interface, generating a unique service ID respectively matched with each concurrent request, including: according to the service demand type of the target interface, extracting request description information matched with the service demand type from each concurrent request respectively; and generating unique service IDs respectively matched with each concurrent request according to the request description information.
The type of the request description information can be determined by manually preset rules; for example, if the manually preset rule is "when the service requirement type is query, extracting user information to generate a random number as request description information", and when it is detected that the service requirement type matched with the concurrent request is query, extracting user information and generating a random number as unique service ID matched with the concurrent request.
S220, generating a unified mark key name according to the interface name of the target interface.
S230, generating a flag key value corresponding to each target thread matched with the service call demand number according to each unique service ID matched with the service call demand number.
The method comprises the steps of determining a mapping relation between each mark key value and each target thread, wherein the mapping relation is unique between each mark key value and each target thread, namely, each target thread has a unique mark key value corresponding to the unique mark key value.
S240, respectively and correspondingly combining the unified flag key names and the flag key values, and establishing and obtaining flag key value pairs respectively corresponding to each target thread.
On the basis of the steps, the mark key values and the target threads have a one-to-one correspondence, so that the mark key value pairs formed by the mark key values and the target threads also have a one-to-one correspondence.
S250, storing each flag key value in the matched target thread respectively.
S260, executing log printing actions in parallel through each target thread, and generating and outputting a printing log.
S270, collecting each print log at a matched storage position according to a mark key value pair corresponding to each output thread of each print log.
According to the technical scheme, when the service call requirement of the target interface is detected, unique service IDs matched with the service call requirement number are generated according to the service requirement type of the target interface, then unified mark key names are generated according to the interface names of the target interface, mark key values respectively corresponding to the target threads matched with the service call requirement number are generated according to the unique service IDs matched with the service call requirement number, then the unified mark key names are respectively combined with the mark key values in a corresponding mode, mark key value pairs respectively corresponding to each target thread are established, each mark key value pair is respectively stored in the matched target threads, log printing actions are executed in parallel through each target thread, print logs are generated and output, finally the print logs are collected to the matched storage positions according to the mark key value pairs respectively corresponding to each printed output thread, the print logs matched with the service call requirement can be generated and output when the service call requirement of the target interface is detected, the log acquisition efficiency is improved, the service log collection end is improved, and the service log collection flexibility is improved.
Example III
Fig. 3 is a schematic structural diagram of a log obtaining device according to a third embodiment of the present invention.
As shown in fig. 3, the apparatus includes:
the flag key value pair establishing module 310 is configured to, when detecting a service call requirement for a target interface, respectively establish a flag key value pair for each target thread included in the target interface according to a service requirement type and an interface name of the target interface;
a flag key value pair storage module 320, configured to store each flag key value pair in a matched target thread, where different target threads have the same flag key name and different flag key values;
The print log output module 330 is configured to execute log printing actions in parallel through each target thread, and generate and output a print log;
And the print log collecting module 340 is configured to collect each print log at a matched storage location according to a flag key value pair corresponding to an output thread of each print log.
According to the technical scheme, when the service call requirement of the target interface is detected, the mark key value pairs are respectively built for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface, then each mark key value pair is respectively stored in the matched target thread, log printing actions are executed in parallel through each target thread to generate and output the printing logs, and finally each printing log is collected to the matched storage position according to the mark key value pairs respectively corresponding to the output threads of each printing log, so that the generation and output of the printing logs matched with the service call requirement when the service call requirement of the target interface is detected can be realized, the log acquisition efficiency is improved, the real-time collection of the logs output when the target interface is called by the service call requirement is realized, and the use flexibility of the service end to the logs is improved.
Based on the above embodiment, the flag key value pair establishing module 310 specifically includes:
The service ID matching unit is used for generating each unique service ID matched with the service call demand quantity according to the service demand type of the target interface when the service call demand of the target interface is detected;
the sign key name generating unit is used for generating a unified sign key name according to the interface name of the target interface;
The sign key value generating unit is used for generating sign key values respectively corresponding to each target thread matched with the service call demand quantity according to each unique service ID matched with the service call demand quantity;
And the marking key value pair acquisition unit is used for respectively and correspondingly combining the unified marking key names with the marking key values to establish and obtain marking key value pairs respectively corresponding to each target thread.
On the basis of the above embodiment, the service ID matching unit is further configured to: when a plurality of concurrent requests initiated for the target interface are detected, generating unique service IDs respectively matched with each concurrent request according to the service demand type of the target interface.
On the basis of the above embodiment, the service ID matching unit further includes:
The request description information extraction unit is used for respectively extracting request description information matched with the service demand type from each concurrent request according to the service demand type of the target interface;
And the service ID generating unit is used for generating unique service IDs respectively matched with each concurrent request according to the request description information.
On the basis of the above embodiment, the flag key value pair storage module 320 further includes: a grouping establishing unit, configured to establish a first-level grouping corresponding to the same identifier key name in each identifier key value in a set storage space after each identifier key value is respectively stored in a matched target thread; and respectively establishing secondary groups respectively corresponding to different sign key values in the primary groups.
Based on the above embodiment, the print log collection module 340 specifically includes:
the log acquisition unit is used for acquiring the current printing log;
the identification unit is used for identifying the current mark key name and the mark key value in the current mark key value pair if the current mark key value pair is contained in the output thread in the current printing log;
The grouping positioning unit is used for positioning a current primary grouping corresponding to the current mark key name in a set storage space and positioning a current secondary grouping corresponding to the current mark key value in the current primary grouping;
and the storage unit is used for storing the current printing log in the current secondary grouping.
On the basis of the above embodiment, the log obtaining unit is further configured to: after the current printing log is acquired, if the output thread of the current printing log does not contain the mark key value pair, the log storage operation is abandoned for the current printing log.
The log obtaining device provided by the embodiment of the invention can execute the log obtaining method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, for example, a log obtaining method.
Accordingly, the method comprises the following steps:
When detecting the service call requirement of the target interface, respectively establishing a mark key value pair for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface;
Storing each mark key value in a matched target thread respectively, wherein different target threads have the same mark key name and different mark key values;
executing log printing actions in parallel through each target thread, and generating and outputting a printing log;
And collecting each print log at the matched storage position according to the mark key value pair corresponding to the output thread of each print log.
In some embodiments, a log acquisition method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of one log acquisition method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a log acquisition method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.

Claims (8)

1. A log obtaining method, comprising:
When detecting the service call requirement of the target interface, respectively establishing a mark key value pair for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface;
Storing each mark key value in a matched target thread respectively, wherein different target threads have the same mark key name and different mark key values, the mark key name of the target thread is generated based on the name of the target interface, and the mark key value is generated based on the service requirement type matched with the target thread;
executing log printing actions in parallel through each target thread, and generating and outputting a printing log; the printing log is a log file output by log printing actions executed by each target thread;
Collecting each printing log to a matched storage position according to a mark key value pair corresponding to an output thread of each printing log;
Wherein after storing each flag key value in the matched target thread, respectively, further comprises: creating a first-level grouping corresponding to the same sign key name in each sign key value in a set storage space; respectively establishing secondary groups respectively corresponding to different sign key values in the primary groups;
The method for collecting the print logs at the matched storage positions according to the mark key value pairs respectively corresponding to the output threads of the print logs comprises the following steps: acquiring a current printing log; if the output thread in the current printing log contains the current mark key value pair, identifying the current mark key name and the mark key value in the current mark key value pair; positioning a current primary grouping corresponding to the current mark key name in a set storage space, and positioning a current secondary grouping corresponding to the current mark key value in the current primary grouping; the current print log is stored in the current secondary packet.
2. The method of claim 1, wherein upon detecting a service call requirement for a target interface, establishing a flag key value pair for each target thread included in the target interface according to a service requirement type and an interface name of the target interface, respectively, comprises:
when detecting the service call requirement of the target interface, generating each unique service ID matched with the service call requirement number according to the service requirement type of the target interface;
generating a unified mark key name according to the interface name of the target interface;
generating a mark key value corresponding to each target thread matched with the service call demand quantity according to each unique service ID matched with the service call demand quantity;
And respectively and correspondingly combining the unified mark key names and the mark key values, and establishing and obtaining mark key value pairs respectively corresponding to each target thread.
3. The method of claim 2, wherein upon detecting a service call demand for the target interface, generating each unique service ID matching the number of service call demands according to the service demand type of the target interface, comprising:
When a plurality of concurrent requests initiated for the target interface are detected, generating unique service IDs respectively matched with each concurrent request according to the service demand type of the target interface.
4. A method according to claim 3, wherein generating a unique service ID for each concurrent request that matches each concurrent request separately according to the service requirement type of the target interface, comprises:
according to the service demand type of the target interface, extracting request description information matched with the service demand type from each concurrent request respectively;
And generating unique service IDs respectively matched with each concurrent request according to the request description information.
5. The method of claim 1, further comprising, after obtaining the current print log:
and if the output thread of the current printing log does not contain the mark key value pair, discarding the execution of log storage operation on the current printing log.
6. A log obtaining apparatus, characterized by comprising:
The mark key value pair establishing module is used for respectively establishing mark key value pairs for each target thread contained in the target interface according to the service requirement type and the interface name of the target interface when the service calling requirement of the target interface is detected;
The storage module of the mark key value pair is used for storing each mark key value pair into a matched target thread, wherein different target threads have the same mark key name and different mark key values, the mark key name of the target thread is generated based on the name of the target interface, and the mark key value is generated based on the service requirement type matched with the target thread;
The printing log output module is used for executing log printing actions in parallel through each target thread, and generating and outputting a printing log; the printing log is a log file output by log printing actions executed by each target thread;
The printing log collecting module is used for collecting each printing log to a matched storage position according to the mark key value pair corresponding to the output thread of each printing log;
Wherein, the sign key value is to the storage module, includes: a grouping establishing unit, configured to establish a first-level grouping corresponding to the same identifier key name in each identifier key value in a set storage space after each identifier key value is respectively stored in a matched target thread; respectively establishing secondary groups respectively corresponding to different sign key values in the primary groups;
Wherein, print log collection module includes: the log acquisition unit is used for acquiring the current printing log; the identification unit is used for identifying the current mark key name and the mark key value in the current mark key value pair if the current mark key value pair is contained in the output thread in the current printing log; the grouping positioning unit is used for positioning the current primary grouping corresponding to the current mark key name in the set storage space and positioning the current secondary grouping corresponding to the current mark key value in the current primary grouping; and the storage unit is used for storing the current printing log in the current secondary grouping.
7. An electronic device, the electronic device comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform a log obtaining method according to any one of claims 1-5.
8. A computer readable storage medium storing computer instructions for causing a processor to perform a log obtaining method according to any one of claims 1-5 when executed.
CN202410033266.XA 2024-01-10 2024-01-10 Log acquisition method, device, equipment and medium Active CN117539840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410033266.XA CN117539840B (en) 2024-01-10 2024-01-10 Log acquisition method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410033266.XA CN117539840B (en) 2024-01-10 2024-01-10 Log acquisition method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN117539840A CN117539840A (en) 2024-02-09
CN117539840B true CN117539840B (en) 2024-07-09

Family

ID=89794290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410033266.XA Active CN117539840B (en) 2024-01-10 2024-01-10 Log acquisition method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117539840B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258973A (en) * 2020-01-17 2020-06-09 广州虎牙科技有限公司 Storage and display method, device, equipment and medium of Redis slow log

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7523470B2 (en) * 2004-12-23 2009-04-21 Lenovo Singapore Pte. Ltd. System and method for detecting keyboard logging
CN102650938B (en) * 2011-02-28 2015-02-18 北京航空航天大学 Management method for log system and log system
CN110377136A (en) * 2019-06-18 2019-10-25 苏州浪潮智能科技有限公司 A kind of PSU original value log recording method and device
US11797510B2 (en) * 2021-04-20 2023-10-24 Netapp, Inc. Key-value store and file system integration
CN116701387A (en) * 2022-02-28 2023-09-05 华为技术有限公司 Data segmentation writing method, data reading method and device
CN114691636A (en) * 2022-04-27 2022-07-01 济南浪潮数据技术有限公司 Log file generation method, device, equipment and storage medium
CN115757304A (en) * 2022-10-31 2023-03-07 中国农业银行股份有限公司 Log storage method, device and system, electronic equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258973A (en) * 2020-01-17 2020-06-09 广州虎牙科技有限公司 Storage and display method, device, equipment and medium of Redis slow log

Also Published As

Publication number Publication date
CN117539840A (en) 2024-02-09

Similar Documents

Publication Publication Date Title
CN114116811B (en) Log processing method, device, equipment and storage medium
CN112860811B (en) Method and device for determining data blood relationship, electronic equipment and storage medium
CN117539840B (en) Log acquisition method, device, equipment and medium
CN116309963B (en) Batch labeling method and device for images, electronic equipment and storage medium
CN117033058A (en) Analysis method, device, equipment and medium for software crash data
CN116955856A (en) Information display method, device, electronic equipment and storage medium
CN114722264A (en) Data query method and device, electronic equipment and storage medium
CN114443802B (en) Interface document processing method and device, electronic equipment and storage medium
CN114595231B (en) Database table generation method and device, electronic equipment and storage medium
CN117809133A (en) Data set management method, device, equipment and medium
CN118012936A (en) Data extraction method, device, equipment and storage medium
US20230130399A1 (en) Wakeup Indicator Monitoring Method, Apparatus and Electronic Device
CN117290306A (en) Log data display method, device, equipment and storage medium
CN116796711A (en) Information summarizing method, device, equipment and medium based on vehicle parts
CN118113916A (en) Data processing method, device, electronic equipment and storage medium
CN116401269A (en) Data query method and device, electronic equipment and storage medium
CN117271840A (en) Data query method and device of graph database and electronic equipment
CN118035511A (en) Recommendation platform, recommendation method, electronic equipment and storage medium
CN116417059A (en) Memory batch test method and system
CN116108254A (en) Object matching method, device, equipment and medium
CN116932623A (en) Conversion method, device and equipment of cloud container scheduling data and storage medium
CN117349016A (en) Resource allocation method, device, equipment and medium
CN118535643A (en) Database synchronization method and device, electronic equipment and storage medium
CN117786453A (en) Method, device, equipment and storage medium for identifying type of cabinet
CN117650967A (en) Multi-cluster index processing method, system, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant