A log uploading method and device, electronic equipment and storage medium
By unifying the management of log uploads based on the correspondence between server type and storage space, the problem of code redundancy in existing log upload systems is solved, and convenient log expansion and maintenance are achieved.
Patent Information
- Application Number
- CN202210897082.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-28
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2042-07-28
AI Technical Summary
In existing technologies, each log type requires a dedicated log upload system, resulting in code redundancy and hindering expansion and maintenance.
By obtaining the server type of the log to be uploaded, determining the target storage space based on the preset correspondence between server type and storage space, and uploading to the target server when the conditions are met, the amount of code is reduced and it is easy to expand.
It enables unified uploading of different types of logs, reduces the amount of code in the log upload system, and facilitates the storage and uploading of new types of logs in the future.
Smart Images

Figure CN115292268B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data transmission, in particular to a log uploading method and device, electronic equipment and storage medium. BACKGROUND
[0002] In order to better analyze user behavior, more accurately recommend products to each user, and analyze whether the design of the product is reasonable and can meet the current user's needs, the server needs to analyze various logs of the user uploaded by the APP (Application) client of the user. For example, the business log recording user behavior such as page stay log and user browsing record log is uploaded to the business server for analysis, the monitoring log such as page loading time log, crash log and interface time-consuming log representing the APP health condition is uploaded to the monitoring server for analysis, and some APPs will make traceless point setting for subsequent deepening of user attributes or habits.
[0003] Because the format, processing method and interfaced server system of these logs are different, a set of log uploading system needs to be specially set for each kind of log to store and upload the log, so that there will be a lot of redundant codes on the APP side, and if a new type of log needs to be uploaded, a new set of codes needs to be developed, which is a large development workload and is not conducive to the extension and maintenance of the subsequent log uploading. SUMMARY
[0004] The purpose of the embodiment of the present application is to provide a log uploading method, device, electronic equipment and storage medium to reduce the code amount of the log uploading system and facilitate the extension of subsequent log uploading. The specific technical solutions are as follows:
[0005] In a first aspect, the embodiment of the present application provides a log uploading method, which comprises:
[0006] obtaining a log to be uploaded, wherein the log to be uploaded carries a server type to be uploaded;
[0007] determining a target storage space corresponding to the server type according to the server type and a preset correspondence between server types and storage spaces;
[0008] storing the log to be uploaded to the target storage space;
[0009] when a log uploading condition is met, reading the log to be uploaded from the target storage space, and uploading the log to be uploaded to a target server according to the server type corresponding to the log to be uploaded.
[0010] Optionally, the step of determining the target storage space corresponding to the server type according to the server type and the preset correspondence between the server type and the storage space comprises:
[0011] sending the log to be uploaded to the manager corresponding to each storage space, so that the manager corresponding to each storage space determines whether the corresponding storage space is used for storing the log to be uploaded according to the server type carried by the log to be uploaded and the preset correspondence between the server type and the storage space, and if so, determines the corresponding storage space as the target storage space.
[0012] Optionally, the method further comprises:
[0013] determining whether the amount of data in the storage space is greater than a first preset threshold according to a first preset time interval;
[0014] if so, deleting the data in the storage space in a preset deletion manner corresponding to the storage space;
[0015] determining whether the amount of data in the storage space after deletion is greater than the first preset threshold;
[0016] if so, deleting the data in the storage space according to the storage time, so that the amount of data in the storage space is not greater than the first preset threshold.
[0017] Optionally, before the step of reading the log to be uploaded from the target storage space and determining the server type corresponding to the log to be uploaded, the method further comprises:
[0018] determining whether the amount of data in the target storage space reaches a second preset threshold according to a second preset time interval;
[0019] if so, determining that the log uploading condition is met.
[0020] Optionally, after the step of uploading the log to be uploaded to the target server, the method further comprises:
[0021] determining whether the log to be uploaded is successfully uploaded;
[0022] if so, deleting the log to be uploaded from the target storage space;
[0023] if not, determining the target log processing manner corresponding to the server type according to the correspondence between the server type and the preset log processing manner, wherein the log processing manner comprises deleting the log and retransmitting the log;
[0024] According to the target log processing mode, the to-be-uploaded log is processed.
[0025] Optionally, the step of obtaining the to-be-uploaded log comprises:
[0026] The original log generated by each preset embedded point is obtained.
[0027] According to a preset data processing mode, the original log is converted into a to-be-uploaded log in a target format.
[0028] Optionally, before the step of uploading the to-be-uploaded log to a target server according to the server type corresponding to the to-be-uploaded log, the method further comprises:
[0029] According to the server type and a preset correspondence between a server type and a callback interface, a target callback interface corresponding to the server type is determined.
[0030] The callback interface is called to convert the to-be-uploaded log from the target format into a log format corresponding to the server type.
[0031] Optionally, the storage space at least comprises a hard disk, a memory and a database.
[0032] In a second aspect, an embodiment of the present application provides a log uploading device, and the device comprises:
[0033] A log obtaining module is configured to obtain a to-be-uploaded log, wherein the to-be-uploaded log carries a server type to be uploaded.
[0034] A storage space determining module is configured to determine a target storage space corresponding to the server type according to the server type and a preset correspondence between a server type and a storage space.
[0035] A log storing module is configured to store the to-be-uploaded log in the target storage space.
[0036] A log uploading module is configured to read the to-be-uploaded log from the target storage space when a log uploading condition is met, and upload the to-be-uploaded log to a target server according to a server type corresponding to the to-be-uploaded log.
[0037] Optionally, the storage space determining module is specifically configured to:
[0038] Send the log to be uploaded to the manager corresponding to each storage space, so that the manager corresponding to each storage space determines whether the corresponding storage space is used for storing the log to be uploaded according to the server type carried by the log to be uploaded and the preset correspondence between the server type and the storage space, and if so, determines the corresponding storage space as the target storage space.
[0039] Optionally, the apparatus further comprises:
[0040] The first storage space determining module is configured to determine whether the data amount in the storage space is greater than a first preset threshold according to a first preset time interval.
[0041] The first data deleting module is configured to delete the data in the storage space by using a preset deleting mode corresponding to the storage space when the determination result of the first storage space determining module is yes.
[0042] The second storage space determining module is configured to determine whether the data amount in the storage space after deletion is greater than the first preset threshold.
[0043] The second data deleting module is configured to delete the data in the storage space according to the storage time when the determination result of the second storage space determining module is yes, so that the data amount in the storage space is not greater than the first preset threshold.
[0044] Optionally, the apparatus further comprises:
[0045] The third storage space determining module is configured to determine whether the data amount in the target storage space reaches a second preset threshold according to a second preset time interval.
[0046] The uploading triggering module is configured to determine that the log uploading condition is met when the determination result is yes.
[0047] Optionally, the apparatus further comprises:
[0048] The uploading determining module is configured to determine whether the log to be uploaded is successfully uploaded.
[0049] The log deleting module is configured to delete the log to be uploaded from the target storage space when the determination result is yes.
[0050] The log processing mode determining module is configured to determine the target log processing mode corresponding to the server type according to the correspondence between the server type and the log processing mode when the determination result is no, wherein the log processing mode comprises deleting the log and retransmitting the log.
[0051] A log processing module is configured to process the to-be-uploaded log according to the target log processing mode.
[0052] Optionally, the log obtaining module comprises:
[0053] An original log obtaining unit is configured to obtain original logs generated by each preset embedded point.
[0054] A log format conversion unit is configured to convert the original logs into to-be-uploaded logs in a target format according to a preset data processing mode.
[0055] Optionally, the apparatus further comprises:
[0056] A callback interface determining module is configured to determine a target callback interface corresponding to the server type according to the server type and a preset correspondence between server types and callback interfaces.
[0057] A log format conversion module is configured to convert the to-be-uploaded log from the target format into a log format corresponding to the server type by calling the callback interface.
[0058] Optionally, the storage space comprises at least a hard disk, a memory and a database.
[0059] In a third aspect, an electronic device is provided, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0060] The memory is configured to store a computer program.
[0061] The processor is configured to execute the program stored in the memory, so as to implement the method steps of any one of the first aspect.
[0062] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to implement the method steps of any one of the first aspect.
[0063] In the solution provided by this invention, an electronic device can acquire logs to be uploaded, wherein the logs to be uploaded carry the type of server to which they are to be uploaded; determine the target storage space corresponding to the server type based on the server type and a preset correspondence between server type and storage space; store the logs to be uploaded in the target storage space; when the log upload conditions are met, read the logs to be uploaded from the target storage space, and upload the logs to the target server according to the server type corresponding to the logs to be uploaded. Since the electronic device can determine the target storage space for storing the logs to be uploaded and upload the logs to the corresponding target server based on the server type contained in the logs and the preset correspondence between server type and storage space for different types of logs to be uploaded, only one log upload system is needed to realize the upload of different types of logs to be uploaded. It is not necessary to write a separate log upload system for each type of log, thus reducing the amount of code in the log upload system. Furthermore, when expanding to other types of logs to be uploaded in the future, it is only necessary to add the correspondence between the server type to which the log to be uploaded and the storage space to the above correspondence to realize the storage and uploading of the logs of that type. There is no need to develop a new log upload system, which facilitates the expansion of the storage and uploading of other types of logs to be uploaded. Attached Figure Description
[0064] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0065] Figure 1 A flowchart of a log upload method provided in an embodiment of the present invention;
[0066] Figure 2 Based on Figure 1 A schematic diagram of a server configuration information storage method in the embodiment shown;
[0067] Figure 3 Based on Figure 1 A schematic diagram of the log distribution and storage method in the embodiment shown;
[0068] Figure 4 Based on Figure 1 Another schematic diagram of the log distribution and storage method in the illustrated embodiment;
[0069] Figure 5 Based on Figure 1 A flowchart of a data deletion method in the embodiment shown;
[0070] Figure 6 Based on Figure 1 A flowchart illustrating a method for determining log upload conditions in the embodiment shown;
[0071] Figure 7 For based on Figure 1 A flowchart of a log upload method in the embodiment shown;
[0072] Figure 8 For based on Figure 1 The illustrated embodiment is a flowchart of a method for processing uploaded logs;
[0073] Figure 9 For based on Figure 1 The flowchart shown is a method for obtaining logs to be uploaded according to the embodiment.
[0074] Figure 10 For based on Figure 1 A flowchart of a log format conversion method in the embodiment shown;
[0075] Figure 11 This is a schematic diagram of the topology on which the log upload method provided in this embodiment of the invention is based;
[0076] Figure 12 This is a schematic diagram of the structure of a log uploading device provided in an embodiment of the present invention;
[0077] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0078] The technical solutions of the present invention will now be described with reference to the accompanying drawings in the embodiments of the present invention.
[0079] To reduce the amount of code in a log upload system and facilitate subsequent expansion of log uploads, embodiments of the present invention provide a log upload method, apparatus, electronic device, computer-readable storage medium, and computer program product. The following first describes a log upload method provided by an embodiment of the present invention.
[0080] The log uploading method provided in this embodiment of the invention can be applied to any electronic device that needs to upload logs, such as a terminal, a server, etc., without specific limitations. For clarity, it will be referred to as an electronic device below.
[0081] like Figure 1 As shown, a log upload method includes:
[0082] S101, retrieve logs to be uploaded;
[0083] The log to be uploaded carries the type of server to which it is to be uploaded.
[0084] S102, Based on the server type and the preset correspondence between server type and storage space, determine the target storage space corresponding to the server type;
[0085] S103, store the log to be uploaded to the target storage space;
[0086] S104, when the log upload conditions are met, read the log to be uploaded from the target storage space, and upload the log to be uploaded to the target server according to the server type corresponding to the log to be uploaded.
[0087] As can be seen, in the solution provided by this embodiment of the invention, the electronic device can obtain logs to be uploaded, wherein the logs to be uploaded carry the server type to be uploaded; determine the target storage space corresponding to the server type according to the server type and the preset correspondence between server type and storage space; store the logs to be uploaded in the target storage space; when the log upload conditions are met, read the logs to be uploaded from the target storage space, and upload the logs to be uploaded to the target server according to the server type corresponding to the logs to be uploaded. Since the electronic device can determine the target storage space for storing the logs to be uploaded and upload the logs to the corresponding target server according to the server type contained in the logs to be uploaded and the preset correspondence between server type and storage space for different types of logs to be uploaded, only one log upload system is needed to realize the upload of different types of logs to be uploaded, without having to write a separate log upload system for each type of log, which can reduce the amount of code in the log upload system. Furthermore, when expanding to other types of logs to be uploaded in the future, it is only necessary to add the correspondence between the server type to which the log to be uploaded and the storage space to the above correspondence to realize the storage and uploading of the logs of that type. There is no need to develop a new log upload system, which facilitates the expansion of the storage and uploading of other types of logs to be uploaded.
[0088] When a server monitors and analyzes electronic devices and the behavior of users using them, it needs to obtain logs to be uploaded generated by multiple tracking points pre-placed in the electronic device. Therefore, the electronic device can obtain the logs to be uploaded generated by each tracking point and upload them to the corresponding server, so that the server can monitor and analyze the electronic device and the behavior of users using it.
[0089] The buried point can be used to listen to events occurring in the running process of the electronic device and judge the events. When the event concerned by the buried point occurs, the buried point can capture the event to generate a log to be uploaded. Because the server types corresponding to each buried point are different, for example, the server type corresponding to the recommendation buried point is a recommendation server, the server type corresponding to the monitoring buried point is a monitoring server, and the server corresponding to the traceless buried point is a server for analyzing user attributes and habits, the buried point can carry the server type to be uploaded when generating the log to be uploaded, so that the electronic device can process the log to be uploaded subsequently.
[0090] When the server needs to monitor and analyze the terminal and the behavior of the terminal user, the log to be uploaded can be a log generated by the terminal. When the server needs to monitor and analyze the server providing the service, the log to be uploaded can be a log generated by the server, which is not limited here.
[0091] After obtaining the log to be uploaded, the electronic device can execute the step S102 to store the log to be uploaded. Because the size, importance, latency requirement, and fault tolerance requirement of the log to be uploaded uploaded to different server types can be different, the electronic device can allocate a corresponding storage space for the log to be uploaded. The storage space can include a hard disk, a memory, and a database, and can also include a floppy disk, an optical disk, and the like, which is not limited here.
[0092] In an embodiment, because the hard disk storage is suitable for a scenario with low latency requirement and large amount of logs; the memory storage is suitable for a scenario with high latency requirement but low fault tolerance requirement; and the database storage is suitable for a scenario with medium latency requirement and high fault tolerance requirement. Therefore, for the log to be uploaded to the real-time recommendation server, the latency requirement is high but the fault tolerance requirement is low, so the memory can be allocated for storage; for the log to be uploaded to the monitoring server, the latency requirement is medium but the fault tolerance requirement is high, so the database can be allocated for storage; and for the log to be uploaded to the server for analyzing user attributes and habits, the latency requirement is low but the data amount is large, so the hard disk can be allocated for storage.
[0093] The delay requirement of the to-be-uploaded log uploaded to different server types can be divided according to the speed requirement of the to-be-uploaded log uploaded to the corresponding server. As an embodiment, if the to-be-uploaded log needs to be uploaded to the corresponding server at a speed of seconds, it can be considered that the delay requirement is high; if the to-be-uploaded log can be uploaded to the corresponding server on the day of generation, it can be considered that the delay requirement is medium; if the to-be-uploaded log can be uploaded to the corresponding server within the week of generation, it can be considered that the delay requirement is low.
[0094] The fault tolerance requirement of the to-be-uploaded log uploaded to different server types can be divided according to the maximum loss rate allowed by the to-be-uploaded log in the process of uploading to the corresponding server. As an embodiment, if the maximum loss rate allowed by the to-be-uploaded log in the process of uploading to the corresponding server is 2%, it can be considered that the fault tolerance requirement is high; if the maximum loss rate allowed by the to-be-uploaded log in the process of uploading to the corresponding server is 5%, it can be considered that the fault tolerance requirement is medium; if the maximum loss rate allowed by the to-be-uploaded log in the process of uploading to the corresponding server is 20%, it can be considered that the fault tolerance requirement is low. The specific division standard of the delay requirement and the fault tolerance requirement can be set according to the actual application requirement, which is not limited here.
[0095] In order to facilitate the storage of the to-be-uploaded log, a correspondence between the server type and the storage space can be established in advance. In this way, after the electronic device obtains the to-be-uploaded log carrying the server type to be uploaded, the electronic device can determine the target storage space for storing the to-be-uploaded log according to the server type carried by the to-be-uploaded log and the preset correspondence between the server type and the storage space, and store it.
[0096] After the electronic device stores the to-be-uploaded log in the target storage space, when the log uploading condition is met in step S104, the electronic device can read the to-be-uploaded log from the target storage space and upload the to-be-uploaded log to the target server according to the server type corresponding to the to-be-uploaded log. The electronic device can periodically determine whether the log uploading condition is met, and of course, other rules can be used to determine whether the log uploading condition is met, for example, the log uploading condition can be determined at a fixed time, and the like, which is not limited here.
[0097] In an implementation, in the process of arranging the implantation point by the electronic device, the server can send the server type and the server address to the electronic device, and the electronic device can pre-establish the correspondence between the server type and the server address according to the above content, so that the electronic device can determine the server address according to the server type to which the to-be-uploaded log is to be uploaded and the pre-set correspondence between the server type and the server address after reading the to-be-uploaded log, and then upload the to-be-uploaded log to the target server according to the server address.
[0098] In order to facilitate the storage and uploading of the to-be-uploaded log, the electronic device can have a storage management unit for managing the storage and uploading operation of the to-be-uploaded log uploaded to different server types. When the storage management unit is initialized, it can pre-save the configuration information corresponding to the server, such as name: type of the server, url: address of the server, time: uploading time interval of the to-be-uploaded log uploaded to the server, type: storage space for storing the to-be-uploaded log uploaded to the server, and the like, and can also save the callback function for calling the callback interface. In an implementation, as shown in Figure 2 It is reasonable that the storage management unit can receive and save the server configuration information sent by the server when it is initialized, and in another implementation, the storage management unit can also receive and save the server configuration information set by the technician, which is not limited here.
[0099] In the scheme provided by the embodiment of the application, the electronic device can determine the target storage space for storing the to-be-uploaded log and upload the to-be-uploaded log to the corresponding target server according to the server type contained in the to-be-uploaded log and the pre-set correspondence between the server type and the storage space, so that only one set of log uploading system can be used to upload different types of to-be-uploaded logs, and a set of log uploading system does not need to be specially written for each type of to-be-uploaded log, which can reduce the code amount of the log uploading system. When other types of to-be-uploaded logs are subsequently expanded, the server type to which the to-be-uploaded log is to be uploaded and the storage space can be added to the above correspondence, so that the storage and uploading of the to-be-uploaded log of this type can be realized without developing a new log uploading system, which facilitates the expansion of the storage and uploading of other types of to-be-uploaded logs.
[0100] As an implementation of the embodiment of the application, the step of determining the target storage space corresponding to the server type according to the server type and the pre-set correspondence between the server type and the storage space can include:
[0101] The log to be uploaded is sent to the manager corresponding to each storage space, so that the manager corresponding to each storage space determines, according to the server type carried by the log to be uploaded and the preset correspondence between the server type and the storage space, whether the corresponding storage space is used to store the log to be uploaded, and if so, determines the corresponding storage space as the target storage space.
[0102] In the process of arranging the embedded point in the electronic device, the server can send the server type of the server and the storage space corresponding to the log generated by the embedded point to the electronic device, and the electronic device can send the above correspondence to the manager corresponding to each storage space, and each manager stores the correspondence.
[0103] For the case that the storage space includes a hard disk, a memory and a database, in an embodiment, as shown in Figure 3 When the electronic device obtains the log to be uploaded, the log to be uploaded can be distributed to the manager corresponding to each storage space, and the manager corresponding to each storage space determines whether the corresponding storage space is used to store the log to be uploaded, and the storage space used to store the log to be uploaded is determined as the target storage space.
[0104] In another embodiment, as shown in Figure 4 When the electronic device obtains the log to be uploaded, the log to be uploaded can be first sent to the manager corresponding to the hard disk, and the manager corresponding to the hard disk determines whether the hard disk is used to store the log to be uploaded, if so, the hard disk is determined as the target storage space, if not, the log to be uploaded is sent to the manager corresponding to the memory, and the manager corresponding to the memory determines whether the memory is used to store the log to be uploaded, if so, the memory is determined as the target storage space, if not, the log to be uploaded is sent to the manager corresponding to the database, and the manager corresponding to the database determines whether the database is used to store the log to be uploaded, if so, the database is determined as the target storage space, if not, it is determined that the current storage space cannot be used to store the log to be uploaded.
[0105] It can be understood that, although Figure 4 only the mode that the log to be uploaded is first sent to the manager corresponding to the hard disk, then to the manager corresponding to the memory, and finally to the manager corresponding to the database is shown, in fact, the order of sending the above log to be uploaded to the manager corresponding to each storage space can be adjusted according to actual needs, and is not limited to Figure 4 the mode shown in the figure.
[0106] In the scheme provided by the embodiment of the present application, the electronic device can send the to-be-uploaded log to the manager corresponding to each storage space, and determine the target storage space by the manager corresponding to each storage space, which can reduce the pressure of the electronic device to a certain extent, and because the to-be-uploaded log has been sent to the manager corresponding to each storage space, when the manager determines that the storage space corresponding to the manager is the target storage space, the to-be-uploaded log can be directly stored, so that the rapid storage of the to-be-uploaded log can be realized.
[0107] As an embodiment of the present application, as shown in Figure 5 The above method can further include:
[0108] S501, determining whether the data amount in the storage space is greater than a first preset threshold according to a first preset time interval;
[0109] In order to avoid that the data amount in the storage space is too large, the electronic device can detect the data amount in the storage space according to a first preset time interval, and determine whether the data amount in the storage space is greater than a first preset threshold, the first preset threshold corresponding to each storage space can be the same or different, which is not limited here.
[0110] S502, if yes, deleting the data in the storage space by using a preset deletion mode corresponding to the storage space;
[0111] If the determination result is yes, it indicates that the data amount in the storage space is too large, which may affect the storage of the subsequent to-be-uploaded log, so it is necessary to delete the data in the storage space, at this time, the electronic device can delete the data in the storage space according to the deletion mode corresponding to the storage space.
[0112] In an embodiment, the electronic device can pre-store the deletion mode corresponding to each storage space, for example, for the memory, its implementation is temporary storage, and the data stored by the memory has high latency requirement, so the deletion mode corresponding to the memory can be to delete the data expired in time. Those skilled in the art can design the deletion mode corresponding to each storage space according to the storage characteristics of the storage space and / or the characteristics of the stored data, which is not limited here.
[0113] S503, determining whether the data amount in the storage space after deletion is greater than the first preset threshold;
[0114] S504, if yes, deleting the data in the storage space according to the storage time, so that the data amount in the storage space is not greater than the first preset threshold.
[0115] The deletion mode corresponding to the storage space can delete specific data, for example, the deletion mode corresponding to the memory can delete data that has expired, but cannot guarantee that the amount of data in the storage space after deleting the data according to the deletion mode is not greater than the first preset threshold, for example, the amount of data occupied by the data that has expired is very small, and deleting the data that has expired cannot significantly reduce the amount of data in the memory. Therefore, after deleting the data in the storage space by the deletion mode corresponding to the storage space, the electronic device can detect the amount of data in the storage space again, and determine whether the amount of data in the storage space is greater than the first preset threshold. If not, it indicates that the amount of data in the current storage space meets the requirement, and the storage space can be detected again after a first preset time interval. If yes, it indicates that the amount of data in the current storage space still does not meet the requirement, and further deletion is needed. At this time, the electronic device can delete the data in the storage space by using the deletion mode common to all storage spaces, that is, the data stored earliest in the storage space is preferentially deleted according to the order of storage time, until the amount of data in the storage space is not greater than the first preset threshold.
[0116] In the scheme provided by the embodiment of the application, the electronic device can detect the amount of data in the storage space according to the first preset time interval, and delete the data in the storage space when the amount of data in the storage space is greater than the first preset threshold, thereby ensuring that the storage space always has a free position, and further ensuring that the electronic device can successfully store the to-be-uploaded log in the storage space when storing the to-be-uploaded log. Moreover, when deleting the data in the storage space, the electronic device can first delete the data by using the deletion mode corresponding to each storage space, and then delete the data by using the deletion mode common to all storage spaces when the deletion mode cannot meet the requirement, so that the influence of the data deletion operation on normal data in the storage space is reduced.
[0117] As an embodiment of the application, as shown in Figure 6 Before the step of reading the to-be-uploaded log from the target storage space and determining the server type corresponding to the to-be-uploaded log, the method can further include:
[0118] S601, determining whether the amount of data in the target storage space reaches a second preset threshold according to a second preset time interval;
[0119] S602, if yes, determining that the log uploading condition is met.
[0120] In order to determine whether the to-be-uploaded log meets the preset log uploading condition, the electronic device can detect the data amount in the target storage space according to a second preset time interval, and determine whether the data amount in the target storage space meets a second preset threshold. The second time interval can be uniformly set by the electronic device for the to-be-uploaded logs uploaded to each server type, or can be respectively set by the electronic device for the to-be-uploaded logs uploaded to each server type. For example, when the server is arranged in the electronic device, the uploading time interval of the to-be-uploaded log corresponding to the server type can be sent to the electronic device, and the electronic device takes the uploading time interval of the to-be-uploaded log corresponding to the server type as the second preset time interval of the to-be-uploaded log uploaded to the server type.
[0121] In an embodiment, as shown in FIG. 1, Figure 7 The electronic device can first detect whether the corresponding application program is started. For example, when the electronic device is a terminal, the electronic device can detect whether the APP in the terminal is started. When the electronic device is a server, the electronic device can detect whether the program in the server is started. This is reasonable and is not limited here.
[0122] When the electronic device detects that the corresponding application program is started, in order not to occupy the starting time of the application program and ensure the fluency of the starting of the application program, the electronic device can delay for a certain time, for example, 10 seconds, and then send the wake-up information to the log sending thread in the electronic device. Then, the electronic device determines whether the log sending thread is connected to the network. If the log sending thread is not connected to the network, the electronic device re-sends the wake-up information to the log sending thread in the electronic device at a second preset time interval, for example, 30 seconds. If the log sending thread is connected to the network, the electronic device further determines whether the data amount in the target storage space meets the second preset threshold, for example, whether the data amount in the target storage space is greater than 100M.
[0123] If the data amount in the target storage space meets the second preset threshold, it means that the data amount in the current target storage space is large, and the uploading step of the to-be-uploaded log can be performed. That is, when the data amount in the target storage space meets the second preset threshold, it can be determined that the log uploading condition is met.
[0124] If the data amount in the target storage space does not meet the second preset threshold, it means that the data amount in the current target storage space is small. At this time, the to-be-uploaded log uploading step does not need to be performed, and the to-be-uploaded log generated subsequently can be stored in the target storage space and then uploaded together. Therefore, in order to avoid frequent uploading and occupation of the resources of the electronic device, when it is determined that the data amount in the storage space does not meet the second preset threshold, the electronic device does not perform the uploading step, but re-sends the wake-up information at a second preset time interval, and determines again whether the network is connected and the data amount in the target storage space.
[0125] In the solution provided by this invention, the electronic device can determine whether the log upload condition is met by judging whether the amount of data in the target storage space reaches a second preset threshold. This ensures that the log to be uploaded is only performed when the amount of data in the target storage space reaches a certain quantity, avoiding frequent uploads that would consume the electronic device's resources. Simultaneously, during this process, the electronic device can also delay waking up the log sending thread and determine whether the log sending thread is connected to the network to ensure smooth application startup and successful upload of the logs to be uploaded.
[0126] As one embodiment of the present invention, such as Figure 8 As shown, after the step of uploading the log to be uploaded to the target server, the method may further include:
[0127] S801, determine whether the log to be uploaded has been successfully uploaded;
[0128] Because there may be server malfunctions preventing the receiving of logs to be uploaded, or the connection may be lost during the upload process, electronic devices can further determine whether the log upload was successful after uploading it to the target server. For example, after uploading the log to the target server, it can be determined whether a response message is received from the target server. If so, the log upload is successful; if not, the log upload was unsuccessful.
[0129] S802, If the upload is successful, delete the log to be uploaded from the target storage space;
[0130] Once the log to be uploaded to the server is successfully uploaded, the log stored in the target storage space becomes useless. Therefore, after the log to be uploaded is successfully uploaded, the electronic device can delete the log from the target storage space, thereby cleaning up the space in the target storage space.
[0131] In one implementation, such as Figure 7 As shown, after the electronic device deletes the logs to be uploaded from the target storage space, it can resend a wake-up message to the log sending thread at a second preset time interval to re-determine whether there is a network connection and the amount of data in the target storage space.
[0132] S803, if the upload fails, the target log processing method corresponding to the server type is determined according to the server type and the preset correspondence between server type and log processing method;
[0133] The log processing methods include deleting logs and retransmitting logs.
[0134] S804, processing the to-be-uploaded log according to the target log processing mode.
[0135] Because the characteristics of the to-be-uploaded log uploaded to different server types are different, the log processing mode to be performed on the to-be-uploaded log uploaded to different server types is also different after the uploading fails. For example, for the to-be-uploaded log uploaded to the real-time recommendation server, the time delay requirement is high, so after the uploading fails, there may be a situation that the to-be-uploaded log expires, so the electronic device can delete the to-be-uploaded log when the uploading of the to-be-uploaded log fails. For example, for the to-be-uploaded log uploaded to the server for analyzing user attributes and habits, the time delay requirement is low, but the data volume of the log is large, so after the uploading fails, the to-be-uploaded log can not be deleted, and the to-be-uploaded log is retransmitted when the log uploading condition is met next time. Therefore, when the to-be-uploaded log fails to be uploaded, the electronic device can determine whether to perform a delete operation or a retransmission operation on the to-be-uploaded log according to the server type carried by the to-be-uploaded log and the preset correspondence between the server type and the log processing mode, and perform the corresponding operation.
[0136] In an embodiment, as shown in Figure 7 If the to-be-uploaded log fails to be uploaded, the electronic device can determine whether to delete the to-be-uploaded log. If yes, the to-be-uploaded log is deleted, the wake-up information is retransmitted after a second preset time interval, and the determination of whether there is a network connection and the data volume in the target storage space is performed again. If no, the wake-up information is retransmitted after a second preset time interval, and the determination of whether there is a network connection and the data volume is performed again. It can be understood that because the electronic device does not delete the to-be-uploaded log at this time, it is determined that there is a network connection and the data volume reaches a second preset threshold, and the to-be-uploaded log is uploaded again when the log uploading is performed, that is, the retransmission operation of the to-be-uploaded log is realized.
[0137] In the scheme provided by the embodiment of the application, the electronic device can delete the to-be-uploaded log from the target storage space when the to-be-uploaded log is successfully uploaded, and can determine the processing mode of the to-be-uploaded log according to the server type to which the to-be-uploaded log is to be uploaded when the to-be-uploaded log fails to be uploaded, so that the cleaning of the target storage space is realized, and the successful uploading of the to-be-uploaded log is ensured to a certain extent.
[0138] As an embodiment of the embodiment of the application, as shown in Figure 9 The step of obtaining the to-be-uploaded log can include:
[0139] S901, obtaining original logs generated by each preset embedded point;
[0140] S902, convert the original log into a target format of the to-be-uploaded log according to a preset data processing manner.
[0141] The electronic device needs to perform unified storage operation and uploading operation on logs generated by each preset embedded point, and the format and content of logs generated by different preset embedded points are different. Therefore, in order to facilitate unified processing of logs generated by different preset embedded points, the electronic device can first acquire original logs generated by each preset embedded point, and then convert the original logs generated by each preset embedded point into a target format of the to-be-uploaded log according to a preset data processing manner, so as to realize the unification of the log format and facilitate subsequent processing of the to-be-uploaded log.
[0142] In an embodiment, the electronic device can represent the information of the original log in the form of a general field, so as to convert the original log into a target format of the to-be-uploaded log. For example, t represents the system time when the original log is generated, and the system time is required to be accurate to ms; v represents the version number of the application program generating the original log, and the version number is represented in the form of string; _c represents the server type to which the original log is to be uploaded, and the server type is represented in the form of string; _id represents a continuous self-incrementing id, and the id is used to identify the order of the original log generated in the preset embedded point, so as to facilitate tracking of log loss and the order of concatenated logs; uid represents a unique device ID, which is used to identify a unique electronic device; and other data is transmitted in the form of a JSON object. The above general fields all start with “_” to avoid conflict with business data.
[0143] In the scheme provided by the embodiment of the application, the electronic device can convert the original logs generated by each preset embedded point into a target format of the to-be-uploaded log, realize the unification of the log format, and facilitate the electronic device to perform unified processing on logs from different preset embedded points.
[0144] As an embodiment of the application, as shown in Figure 10 Before the above step of uploading the to-be-uploaded log to a target server according to the server type corresponding to the to-be-uploaded log, the above method can further include:
[0145] S1001, determining a target callback interface corresponding to the server type according to the server type and a preset correspondence between server types and callback interfaces;
[0146] S1002, converting the to-be-uploaded log from the target format into a log format corresponding to the server type by calling the callback interface.
[0147] Because the preset embedded points are arranged in the electronic device by the server in advance, the format of the log processed by the server corresponds to the format of the original log generated by the preset embedded point, but the electronic device converts the original log generated by each preset embedded point into the target format of the to-be-uploaded log when obtaining the to-be-uploaded log, so that the server needs to convert the format of the to-be-uploaded log after receiving the to-be-uploaded log in the target format, and then can perform reading and processing operations on the to-be-uploaded log. Therefore, in order for the server to directly perform reading and processing operations on the to-be-uploaded log, the electronic device can convert the format of the to-be-uploaded log into a log format corresponding to the server type of the server before uploading the to-be-uploaded log to the server.
[0148] In an implementation manner, when the server arranges the preset embedded points in the electronic device, the server type of the server and the corresponding callback interface can be sent to the electronic device, and the electronic device can pre-establish the correspondence between the server type and the callback interface according to the above content, wherein the callback interface corresponding to each server type can convert the to-be-uploaded log from the target format into a log format corresponding to the server type, and therefore, the electronic device can call the corresponding callback interface according to the server type to which the to-be-uploaded log is to be uploaded and the preset correspondence between the server type and the callback interface before uploading the to-be-uploaded log, and convert the format of the to-be-uploaded log.
[0149] In the scheme provided by the embodiment of the application, the electronic device can convert the to-be-uploaded log from the target format into a log format corresponding to the server type to which the to-be-uploaded log is to be uploaded according to the pre-configured callback interface before uploading the to-be-uploaded log, so that the server can directly process the to-be-uploaded log.
[0150] The following describes the log uploading method provided by the embodiment of the application based on Figure 11 The log uploading method provided by the embodiment of the application is exemplarily introduced as follows. Figure 11 As shown in the figure, the preset embedded points in the electronic device can send the to-be-uploaded log to the memory in the electronic device, and the memory determines the storage space for storing the to-be-uploaded log, and the storage space can be configured with storage space configuration information, for example, the correspondence between the server type and the storage space. The electronic device can send to the corresponding server according to the server type to which the to-be-uploaded log is to be uploaded, for example, a business server or a monitoring server, wherein each server has server configuration information, and in the process of arranging the preset embedded points in the electronic device, the server can send the configuration information of the server to the electronic device, for example, the identification of the server, the address of the server, the upload time interval of the log uploaded to the server, the storage space of the log, and the callback interface corresponding to the server.
[0151] In the scheme provided by the embodiment of the present application, the electronic device can determine the target storage space for storing the to-be-uploaded log and upload the to-be-uploaded log to the corresponding target server according to the server type contained in the to-be-uploaded log and the preset correspondence between the server type and the storage space, for different types of to-be-uploaded logs, so that the uploading of different types of to-be-uploaded logs can be realized by only one set of log uploading system, and a log uploading system does not need to be specially written for each type of to-be-uploaded log, which can reduce the code amount of the log uploading system. Moreover, when other types of to-be-uploaded logs are subsequently expanded, the server type to which the to-be-uploaded log is to be uploaded and the storage space are only needed to be added in the above-mentioned correspondence, so that the storage and uploading of the to-be-uploaded log of this type can be realized, without the need of developing a new log uploading system, which facilitates the expansion of the storage and uploading of other types of to-be-uploaded logs.
[0152] Corresponding to the above-mentioned log uploading method, the embodiment of the present application further provides a log uploading device. The log uploading device provided by the embodiment of the present application is introduced below.
[0153] As shown in Figure 12 A log uploading device, the device comprises:
[0154] A log obtaining module 1210 is configured to obtain a to-be-uploaded log, wherein the to-be-uploaded log carries a server type to be uploaded;
[0155] A storage space determining module 1220 is configured to determine a target storage space corresponding to the server type according to the server type and a preset correspondence between the server type and the storage space;
[0156] A log storage module 1230 is configured to store the to-be-uploaded log to the target storage space;
[0157] A log uploading module 1240 is configured to read the to-be-uploaded log from the target storage space when a log uploading condition is met, and upload the to-be-uploaded log to a target server according to the server type corresponding to the to-be-uploaded log.
[0158] It can be seen that in the scheme provided by the embodiment of the application, the electronic device can acquire the to-be-uploaded log, wherein the to-be-uploaded log carries a server type to be uploaded; a target storage space corresponding to the server type is determined according to the server type and a preset correspondence between the server type and the storage space; the to-be-uploaded log is stored in the target storage space; when a log uploading condition is met, the to-be-uploaded log is read from the target storage space, and the to-be-uploaded log is uploaded to a target server according to the server type corresponding to the to-be-uploaded log. Since the electronic device can determine the target storage space for storing the to-be-uploaded log and upload the to-be-uploaded log to the corresponding target server according to the server type included in the to-be-uploaded log and the preset correspondence between the server type and the storage space for different types of to-be-uploaded logs, only one set of log uploading system is needed to implement the uploading of different types of to-be-uploaded logs, and a set of log uploading system does not need to be specially written for each type of to-be-uploaded log, thereby reducing the code amount of the log uploading system. Moreover, when other types of to-be-uploaded logs are subsequently expanded, the server type to be uploaded by the type of to-be-uploaded log and the storage space are only needed to be added in the above correspondence, so that the storage and uploading of the type of to-be-uploaded log can be implemented without developing a new log uploading system, and the storage and uploading of other types of to-be-uploaded logs are facilitated.
[0159] As an implementation manner of the embodiment of the application, the storage space determination module 1220 can be specifically used for:
[0160] The to-be-uploaded log is sent to a manager corresponding to each storage space, so that the manager corresponding to each storage space determines whether the corresponding storage space is used for storing the to-be-uploaded log according to the server type carried by the to-be-uploaded log and the preset correspondence between the server type and the storage space, and if so, the corresponding storage space is determined as a target storage space.
[0161] As an implementation manner of the embodiment of the application, the apparatus can further include:
[0162] The first storage space determination module is configured to determine whether the data amount in the storage space is greater than a first preset threshold value according to a first preset time interval;
[0163] The first data deletion module is configured to delete the data in the storage space by using a preset deletion manner corresponding to the storage space when the determination result of the first storage space determination module is yes;
[0164] The second storage space determination module is configured to determine whether the data amount in the storage space after deletion is greater than the first preset threshold value;
[0165] The second data deletion module is configured to delete data in the storage space according to storage time when the result of the judgment of the second storage space judgment module is yes, so that the amount of data in the storage space is not greater than the first preset threshold.
[0166] As an embodiment of the present application, the device can further include:
[0167] The third storage space judgment module is configured to judge whether the amount of data in the target storage space reaches a second preset threshold according to a second preset time interval.
[0168] The upload trigger module is configured to determine that the log upload condition is met when the result of the judgment is yes.
[0169] As an embodiment of the present application, the device can further include:
[0170] The upload judgment module is configured to judge whether the to-be-uploaded log is uploaded successfully.
[0171] The log deletion module is configured to delete the to-be-uploaded log from the target storage space when the result of the judgment is yes.
[0172] The log processing mode determination module is configured to determine a target log processing mode corresponding to the server type according to the server type and a preset correspondence between server types and log processing modes when the result of the judgment is no, wherein the log processing mode includes deleting a log and retransmitting a log.
[0173] The log processing module is configured to process the to-be-uploaded log according to the target log processing mode.
[0174] As an embodiment of the present application, the log acquisition module 1210 can include:
[0175] The original log acquisition unit is configured to acquire original logs generated by each preset embedded point.
[0176] The log format conversion unit is configured to convert the original logs into to-be-uploaded logs in a target format according to a preset data processing mode.
[0177] As an embodiment of the present application, the device can further include:
[0178] The callback interface determination module is configured to determine a target callback interface corresponding to the server type according to the server type and a preset correspondence between server types and callback interfaces.
[0179] The log format conversion module is configured to invoke the callback interface to convert the to-be-uploaded log from the target format to a log format corresponding to the server type.
[0180] As an embodiment of the present application, the storage space can include at least a hard disk, a memory and a database.
[0181] The present application also provides an electronic device, which comprises Figure 13 As shown in the figure, the electronic device comprises a processor 1301, a communication interface 1302, a memory 1303 and a communication bus 1304, wherein the processor 1301, the communication interface 1302 and the memory 1303 communicate with each other through the communication bus 1304,
[0182] The memory 1303 is configured to store a computer program.
[0183] The processor 1301 is configured to execute the program stored in the memory 1303 to implement the following steps:
[0184] It can be seen that in the scheme provided by the present application, the electronic device can acquire the to-be-uploaded log, wherein the to-be-uploaded log carries the server type to be uploaded; according to the server type and the preset corresponding relationship between the server type and the storage space, the target storage space corresponding to the server type is determined; the to-be-uploaded log is stored in the target storage space; when the log uploading condition is met, the to-be-uploaded log is read from the target storage space, and the to-be-uploaded log is uploaded to the target server according to the server type corresponding to the to-be-uploaded log. Since the electronic device can determine the target storage space for storing the to-be-uploaded log and upload the to-be-uploaded log to the corresponding target server according to the server type contained in the to-be-uploaded log and the preset corresponding relationship between the server type and the storage space for different types of to-be-uploaded logs, only one set of log uploading system is needed to realize the uploading of different types of to-be-uploaded logs, and a set of log uploading system does not need to be specially written for each type of to-be-uploaded log, which can reduce the code amount of the log uploading system. And when other types of to-be-uploaded logs are subsequently expanded, only the corresponding relationship between the server type to be uploaded by the type of to-be-uploaded log and the storage space needs to be added in the above-mentioned corresponding relationship, so that the storage and uploading of the type of to-be-uploaded log can be realized without developing a new log uploading system, which facilitates the expansion of the storage and uploading of other types of to-be-uploaded logs.
[0185] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0186] The communication interface is used for communication between the terminal and other devices.
[0187] The memory can include a Random Access Memory (RAM) and can also include a non-volatile memory, such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the processor.
[0188] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc. It can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0189] In another embodiment provided by the application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the log uploading method in any of the above embodiments.
[0190] In another embodiment provided by the application, a computer program product containing instructions is also provided, and when the computer program product is run on a computer, the computer is caused to execute the log uploading method in any of the above embodiments.
[0191] In the embodiments described above, all or some of the steps can be implemented by software, hardware or firmware, or any combination thereof. When implemented by software, all or some of the steps can be implemented in the form of one or more computer programs. The computer program can be stored in any computer readable medium, and loaded into the computer for execution. The computer readable medium includes computer storage media and communication media. The computer storage media includes any tangible or physical medium for storing or transmitting the program. The computer storage media can be a volatile (e.g., RAM) or non-volatile (e.g., ROM, disk, or CD) storage medium. The communication media typically include computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and includes any information delivery media. The computer readable media does not include carrier waves or other transient signals.
[0192] It should be noted that, in the specification, the relative terms such as first and second, etc., are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. In addition, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0193] Each of the embodiments in the specification is described in a related manner, and the same or similar parts between each of the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the device, electronic device, computer readable storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0194] The above merely provides the preferred embodiments of the application, and not intended to limit the protection scope of the application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the application shall fall within the protection scope of the application.
Claims
1. A log upload method characterized by, The method is applied to an electronic device and comprises the following steps: Obtaining original logs generated by preset embedded points, wherein the preset embedded points are arranged in the electronic device by a server, and for each server, the format of logs processed by the server corresponds to the format of original logs generated by the preset embedded points arranged by the server in advance; Converting the original logs into target-format to-be-uploaded logs according to a preset data processing mode, so as to realize the unification of log formats, wherein the to-be-uploaded logs carry a server type to be uploaded; Determining a target storage space corresponding to the server type according to the server type and a preset correspondence between server types and storage spaces; Storing the to-be-uploaded logs in the target storage space; When a log uploading condition is met, reading the to-be-uploaded logs from the target storage space, determining a target callback interface corresponding to the server type according to the server type and a preset correspondence between server types and callback interfaces, converting the to-be-uploaded logs from the target format into a log format corresponding to the server type by calling the callback interface, and uploading the to-be-uploaded logs to a target server according to the server type corresponding to the to-be-uploaded logs.
2. The method of claim 1, wherein, The step of determining the target storage space corresponding to the server type according to the server type and the preset correspondence between server types and storage spaces comprises the following steps: Sending the to-be-uploaded logs to managers corresponding to the storage spaces, so that the managers corresponding to the storage spaces determine whether the corresponding storage spaces are used to store the to-be-uploaded logs according to the server type carried by the to-be-uploaded logs and the preset correspondence between server types and storage spaces, and if so, the corresponding storage spaces are determined as the target storage space.
3. The method of claim 2, wherein, The method further comprises the following steps: Determining whether the amount of data in the storage space is greater than a first preset threshold at a first preset time interval; If so, deleting the data in the storage space by using a preset deletion mode corresponding to the storage space; Determining whether the amount of data in the storage space after deletion is greater than the first preset threshold; If so, deleting the data in the storage space according to storage time, so that the amount of data in the storage space is not greater than the first preset threshold.
4. The method of claim 1, wherein, Before the step of reading the to-be-uploaded logs from the target storage space and determining the server type corresponding to the to-be-uploaded logs, the method further comprises the following steps: Determining whether the amount of data in the target storage space reaches a second preset threshold at a second preset time interval; If so, it is determined that the log uploading condition is met.
5. The method of claim 1, wherein, After the step of uploading the to-be-uploaded logs to the target server, the method further comprises the following steps: Determining whether the to-be-uploaded logs are uploaded successfully; If so, deleting the to-be-uploaded logs from the target storage space. If the uploading fails, a target log processing mode corresponding to the server type is determined according to the server type and a preset corresponding relationship between the server type and the log processing mode, wherein the log processing mode includes deleting the log and retransmitting the log; The log processing mode includes deleting the log and retransmitting the log.
6. The method according to any one of claims 1 to 5, characterized in that, The storage space at least includes a hard disk, a memory and a database.
7. A log upload apparatus characterized by comprising: The device is applied to an electronic device and includes: A log obtaining module is configured to obtain original logs generated by preset buries, convert the original logs into target format to-be-uploaded logs according to a preset data processing mode, and realize the unification of log formats, wherein the preset buries are arranged in the electronic device by a server, for each server, the format of logs processed by the server corresponds to the format of original logs generated by the preset buries arranged by the server in advance, and the to-be-uploaded logs carry a server type to be uploaded; A storage space determining module is configured to determine a target storage space corresponding to the server type according to the server type and a preset corresponding relationship between the server type and the storage space; A log storage module is configured to store the to-be-uploaded logs into the target storage space; A log uploading module is configured to read the to-be-uploaded logs from the target storage space when a log uploading condition is met, and upload the to-be-uploaded logs to a target server according to the server type corresponding to the to-be-uploaded logs. The device further includes: A callback interface determining module is configured to determine a target callback interface corresponding to the server type according to the server type and a preset corresponding relationship between the server type and the callback interface before the log uploading module uploads the to-be-uploaded logs to the target server; A log format converting module is configured to convert the to-be-uploaded logs from the target format to a log format corresponding to the server type by calling the callback interface.
8. The apparatus of claim 7, wherein, The storage space determining module is specifically configured to: Send the to-be-uploaded logs to managers corresponding to the storage spaces, so that the managers corresponding to the storage spaces determine whether the corresponding storage spaces are used to store the to-be-uploaded logs according to the server type carried by the to-be-uploaded logs and the preset corresponding relationship between the server type and the storage space, and if so, determine the corresponding storage space as the target storage space.
9. The apparatus of claim 8, wherein, The device further includes: A first storage space judging module is configured to judge whether a data amount in the storage space is greater than a first preset threshold according to a first preset time interval; A first data deleting module is configured to delete data in the storage space by using a preset deleting mode corresponding to the storage space when the judgment result of the first storage space judging module is yes; A second storage space judging module is configured to judge whether the data amount in the storage space after deletion is greater than the first preset threshold. The second data deletion module is configured to delete data in the storage space according to storage time when the result of the judgment of the second storage space judgment module is yes, so that the amount of data in the storage space is not greater than the first preset threshold.
10. The apparatus of claim 7, wherein, The device further comprises: The third storage space judgment module is configured to judge whether the amount of data in the target storage space reaches a second preset threshold according to a second preset time interval. The upload trigger module is configured to determine that the log uploading condition is satisfied when the result of the judgment is yes.
11. The apparatus of claim 7, wherein, The device further comprises: The upload judgment module is configured to judge whether the to-be-uploaded log is successfully uploaded. The log deletion module is configured to delete the to-be-uploaded log from the target storage space when the result of the judgment is yes. The log processing mode determination module is configured to determine a target log processing mode corresponding to the server type according to the server type and a preset correspondence between server types and log processing modes when the result of the judgment is no, wherein the log processing mode comprises deleting a log and retransmitting a log. The log processing module is configured to process the to-be-uploaded log according to the target log processing mode.
12. The device of any one of claims 7-11, wherein, The storage space at least comprises a hard disk, a memory and a database.
13. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored on the memory to implement the method steps in any one of claims 1-6.
14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1-6.