CN105183621A - Multithreading based log management method and system - Google Patents
Multithreading based log management method and system Download PDFInfo
- Publication number
- CN105183621A CN105183621A CN201510505875.1A CN201510505875A CN105183621A CN 105183621 A CN105183621 A CN 105183621A CN 201510505875 A CN201510505875 A CN 201510505875A CN 105183621 A CN105183621 A CN 105183621A
- Authority
- CN
- China
- Prior art keywords
- daily record
- thread
- variable parameter
- class object
- module
- 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.)
- Pending
Links
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The present invention provides a multi-threading based log management method and system. The method comprises the following steps: after log class object receiving request for invoking thread, acquiring a variable parameter corresponding to the thread; and by means of the variable parameter corresponding to the thread, the log class object outputting the log into a log file according to log settings corresponding to the thread. Therefore, in a multi-threading environment, each thread has a clear log file respectively, thereby ensuring the correctness of a log output result.
Description
Technical field
The invention belongs to log management field, particularly relate to a kind of blog management method based on multithreading and system.
Background technology
In prior art, application program needs daily record to carry out the running status of logging program, facilitates the issue track in later stage to locate, in the design of log system, generally have the setting that a total log system carrys out these daily records of unified management, as position, output level, content etc.
In single threaded application program, the unidirectional daily record of usual use one is to the important log information in certain file output application program operational process, but in multi-thread environment, when each thread needs output journal, because considering the synchronous of cross-thread, the easy entanglement of daily record that each thread exports, thus make journal file be not easy to read and follow the tracks of.
Figure 1 shows that log management structural drawing of the prior art, comprise thread cluster (thread 1, thread 2 ... thread n), be arranged in shared variable, the journal file of daily record object; Thread 1, thread 2 ... log information exports in journal file by the shared variable that thread n calls in daily record object respectively.
But such scheme exists following problem: different threads calls the shared variable in daily record object respectively, and corresponding assignment is carried out to shared variable, owing to influencing each other between thread, then easily cause the entanglement of daily record Output rusults.
Summary of the invention
The invention provides a kind of blog management method based on multithreading and system, to solve the problem.
The invention provides a kind of blog management method based on multithreading.Said method comprises the following steps:
After daily record class object receiving thread call request, obtain the variable parameter that described thread is corresponding;
Described daily record class object, by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file.
The present invention also provides a kind of Log Administration System based on multithreading, comprises acquisition module, journal output module; Wherein, described acquisition module is connected with described journal output module;
Described acquisition module, after receiving thread call request, obtains variable parameter corresponding to described thread and described variable parameter is sent to described journal output module;
Described journal output module, for by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file.
By following scheme: after daily record class object receiving thread call request, obtain the variable parameter that described thread is corresponding; Described daily record class object, by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file; Achieve under multi-thread environment, each thread has separately journal file clearly, ensure that the correctness of daily record Output rusults.
By following scheme: configure daily record corresponding to different threads in advance and arrange in daily record class object, wherein, described daily record arranges and comprises iog location setting, the setting of daily record output level; Make daily record Output rusults have more personalization and specific aim, greatly improve Consumer's Experience.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide a further understanding of the present invention, and form a application's part, schematic description and description of the present invention, for explaining the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Figure 1 shows that log management structural drawing of the prior art;
Figure 2 shows that the blog management method processing flow chart based on multithreading of the embodiment of the present invention 1;
Figure 3 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 2;
Figure 4 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 3;
Figure 5 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 4.
Embodiment
Hereinafter also describe the present invention in detail with reference to accompanying drawing in conjunction with the embodiments.It should be noted that, when not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.
Figure 2 shows that the blog management method processing flow chart based on multithreading of the embodiment of the present invention 1, comprise the following steps:
Step 201: after daily record class object receiving thread call request, obtain the variable parameter that described thread is corresponding;
Further, described daily record class object refers to Logger class.
Further, after daily record class object receiving thread call request, before obtaining variable parameter corresponding to described thread, also comprise:
Variable parameter and thread corresponding relation are set in daily record class object in advance, as shown in table 1:
Variable parameter and thread mapping table
Thread | Variable parameter |
Thread 1 | Variable parameter A |
Thread 2 | Variable parameter B |
Thread 3 | Variable parameter C |
… | … |
Thread n | Variable parameter N |
Table 1
Further, after daily record class object receiving thread call request, before obtaining variable parameter corresponding to described thread, also comprise:
In daily record class object, configure daily record corresponding to different threads in advance arrange, as shown in table 2:
Thread and daily record arrange mapping table
Thread | Daily record is arranged |
Thread 1 | Daily record arranges a |
Thread 2 | Daily record arranges b |
Thread 3 | Daily record arranges c |
… | … |
Thread n | Daily record arranges n |
Table 2
Wherein, described daily record arranges and comprises iog location setting, the setting of daily record output level.
Step 202: described daily record class object, by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record exported in journal file.
Further, described daily record class object is by variable parameter corresponding to described thread, and arrange according to the daily record corresponding with described thread, process daily record exported in journal file is:
If described daily record class object is Logger class, then described daily record class object is by variable parameter corresponding to described thread, arranges, call the Write () class in Logger class, daily record exported in journal file according to the daily record corresponding with described thread.
Figure 3 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 2, comprise acquisition module, journal output module; Wherein, described acquisition module is connected with described journal output module;
Described acquisition module, after receiving thread call request, obtains variable parameter corresponding to described thread and described variable parameter is sent to described journal output module;
Described journal output module, for by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file.
Figure 4 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 3, the basis of Fig. 3 adds " arranging module ", wherein, the described module that arranges is connected with described acquisition module, described journal output module respectively;
Described module is set, for arranging variable parameter and thread corresponding relation in advance in daily record class object; Also arrange for configuring daily record corresponding to different threads in advance in daily record class object.
Figure 5 shows that the Log Administration System structural drawing based on multithreading of the embodiment of the present invention 4, on the basis of Fig. 4, add " daily record memory module "; Wherein, described daily record memory module is connected with described journal output module;
Described daily record memory module, for storing the log information that described journal output module exports.
By following scheme: after daily record class object receiving thread call request, obtain the variable parameter that described thread is corresponding; Described daily record class object, by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file; Achieve under multi-thread environment, each thread has separately journal file clearly, ensure that the correctness of daily record Output rusults.
By following scheme: configure daily record corresponding to different threads in advance and arrange in daily record class object, wherein, described daily record arranges and comprises iog location setting, the setting of daily record output level; Make daily record Output rusults have more personalization and specific aim, greatly improve Consumer's Experience.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.
Claims (10)
1. based on a blog management method for multithreading, it is characterized in that, comprise the following steps:
After daily record class object receiving thread call request, obtain the variable parameter that described thread is corresponding;
Described daily record class object, by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file.
2. method according to claim 1, is characterized in that, described daily record class object refers to Logger class.
3. method according to claim 1, is characterized in that, after daily record class object receiving thread call request, before obtaining variable parameter corresponding to described thread, also comprises:
Variable parameter and thread corresponding relation are set in daily record class object in advance.
4. method according to claim 1, is characterized in that, after daily record class object receiving thread call request, before obtaining variable parameter corresponding to described thread, also comprises:
In daily record class object, configure daily record corresponding to different threads in advance arrange.
5. method according to claim 4, is characterized in that, described daily record arranges and comprises iog location setting, the setting of daily record output level.
6. method according to claim 1, is characterized in that, described daily record class object is by variable parameter corresponding to described thread, and arrange according to the daily record corresponding with described thread, process daily record exported in journal file is:
If described daily record class object is Logger class, then described daily record class object is by variable parameter corresponding to described thread, arranges, call the Write () class in Logger class, daily record exported in journal file according to the daily record corresponding with described thread.
7. based on a Log Administration System for multithreading, it is characterized in that, comprise acquisition module, journal output module; Wherein, described acquisition module is connected with described journal output module;
Described acquisition module, after receiving thread call request, obtains variable parameter corresponding to described thread and described variable parameter is sent to described journal output module;
Described journal output module, for by variable parameter corresponding to described thread, arranges according to the daily record corresponding with described thread, daily record is exported in journal file.
8. system according to claim 7, is characterized in that, also comprises and arranges module; Wherein, the described module that arranges is connected with described acquisition module, described journal output module respectively;
Described module is set, for arranging variable parameter and thread corresponding relation in advance in daily record class object; Also arrange for configuring daily record corresponding to different threads in advance in daily record class object.
9. system according to claim 8, is characterized in that, described daily record arranges and comprises iog location setting, the setting of daily record output level.
10. system according to claim 8, is characterized in that, also comprises daily record memory module; Wherein, described daily record memory module is connected with described journal output module;
Described daily record memory module, for storing the log information that described journal output module exports.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510505875.1A CN105183621A (en) | 2015-08-17 | 2015-08-17 | Multithreading based log management method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510505875.1A CN105183621A (en) | 2015-08-17 | 2015-08-17 | Multithreading based log management method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105183621A true CN105183621A (en) | 2015-12-23 |
Family
ID=54905713
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510505875.1A Pending CN105183621A (en) | 2015-08-17 | 2015-08-17 | Multithreading based log management method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105183621A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105955972A (en) * | 2016-02-01 | 2016-09-21 | 上海华测导航技术股份有限公司 | Receiver log management system and method |
CN107577579A (en) * | 2017-09-15 | 2018-01-12 | 通鼎互联信息股份有限公司 | A kind of log recording method and device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102650938A (en) * | 2011-02-28 | 2012-08-29 | 北京航空航天大学 | Management method for log system and log system |
CN103368756A (en) * | 2012-03-29 | 2013-10-23 | 福建星网视易信息系统有限公司 | A management system for monitoring the operation log of an embedded system |
US20140082184A1 (en) * | 2012-09-14 | 2014-03-20 | Alibaba Group Holding Limited | Method and system for monitoring execution of user request in distributed system |
-
2015
- 2015-08-17 CN CN201510505875.1A patent/CN105183621A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102650938A (en) * | 2011-02-28 | 2012-08-29 | 北京航空航天大学 | Management method for log system and log system |
CN103368756A (en) * | 2012-03-29 | 2013-10-23 | 福建星网视易信息系统有限公司 | A management system for monitoring the operation log of an embedded system |
US20140082184A1 (en) * | 2012-09-14 | 2014-03-20 | Alibaba Group Holding Limited | Method and system for monitoring execution of user request in distributed system |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105955972A (en) * | 2016-02-01 | 2016-09-21 | 上海华测导航技术股份有限公司 | Receiver log management system and method |
CN107577579A (en) * | 2017-09-15 | 2018-01-12 | 通鼎互联信息股份有限公司 | A kind of log recording method and device |
CN107577579B (en) * | 2017-09-15 | 2020-10-27 | 通鼎互联信息股份有限公司 | Log recording method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107066319B (en) | Multi-dimensional scheduling system for heterogeneous resources | |
CN105320085B (en) | The acquisition method and device of industrial automation data, system | |
CN108052374B (en) | Method and device for deploying container microservice | |
US10007627B2 (en) | Method and apparatus for automatic signal exchange between multiple embedded CPU boards | |
CN102609520B (en) | Method for exporting model data of substation by filtering | |
CN102789491B (en) | A kind of configurable data subscription and delivery system and method thereof | |
CN104202383A (en) | Centralized configuration distribution and management method in distributed cluster environment | |
CN108009258B (en) | Data acquisition and analysis platform capable of being configured online | |
CN103064717B (en) | A kind of apparatus and method of parallel installation of software for cluster system | |
CN103942052A (en) | Service container engine | |
CN102915344B (en) | SQL (structured query language) statement processing method and device | |
CN103327080A (en) | Method and device for establishing control system of internet of things | |
CN105183621A (en) | Multithreading based log management method and system | |
CN113656503A (en) | Data synchronization method, device and system and computer readable storage medium | |
CN106250571A (en) | The method and system that a kind of ETL data process | |
CN106815027A (en) | A kind of high resiliency calculating platform for power network multidimensional business composite computing | |
CN105847339A (en) | Smart medical service platform | |
CN102215264B (en) | Method and device for supporting multi-tenancy data and service customized running | |
CN110019246A (en) | A kind of poverty alleviation big data visual information system | |
CN104410511A (en) | Server management method and system | |
CN103167035A (en) | Method for solving NameNode single-point failure in hadoop distributed file system (HDFS) | |
CN112966478A (en) | Format conversion method and device for table data and storage medium | |
CN110109986B (en) | Task processing method, system, server and task scheduling system | |
WO2020006572A3 (en) | Data stream identity | |
CN116204189A (en) | Data processing method based on sql, server and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20151223 |
|
RJ01 | Rejection of invention patent application after publication |