CN108121789B - Log management method and system - Google Patents

Log management method and system Download PDF

Info

Publication number
CN108121789B
CN108121789B CN201711376214.9A CN201711376214A CN108121789B CN 108121789 B CN108121789 B CN 108121789B CN 201711376214 A CN201711376214 A CN 201711376214A CN 108121789 B CN108121789 B CN 108121789B
Authority
CN
China
Prior art keywords
log
log information
address field
module
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711376214.9A
Other languages
Chinese (zh)
Other versions
CN108121789A (en
Inventor
张良羽
郭连俊
杨慎东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Hirose Opto Co Ltd
Original Assignee
Suzhou Hirose Opto Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Hirose Opto Co Ltd filed Critical Suzhou Hirose Opto Co Ltd
Priority to CN201711376214.9A priority Critical patent/CN108121789B/en
Publication of CN108121789A publication Critical patent/CN108121789A/en
Application granted granted Critical
Publication of CN108121789B publication Critical patent/CN108121789B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07CTIME OR ATTENDANCE REGISTERS; REGISTERING OR INDICATING THE WORKING OF MACHINES; GENERATING RANDOM NUMBERS; VOTING OR LOTTERY APPARATUS; ARRANGEMENTS, SYSTEMS OR APPARATUS FOR CHECKING NOT PROVIDED FOR ELSEWHERE
    • G07C3/00Registering or indicating the condition or the working of machines or other apparatus, other than vehicles
    • G07C3/005Registering or indicating the condition or the working of machines or other apparatus, other than vehicles during manufacturing process

Landscapes

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

Abstract

The invention relates to a log management method and a system, which are independent of a product production method and a product production main program, and can be called by the main program, log information is stored in a shared memory when the main program is called, the log information is read out from the shared memory and recorded by a log reading module, if necessary, the log is displayed and analyzed, and the log information is updated by a log updating module. When the main program is abnormal and can not run normally, the log management system records normally, and the problem of incomplete log record caused by the abnormal main program is solved.

Description

Log management method and system
Technical Field
The invention relates to a log management method and a log management system, and belongs to the technical field of computers.
Background
The production log records data information in a series of production processes in the production process, and the complete production log can realize the traceability of products. The data information recorded in the production log may include: the time and date information such as the starting time, the ending time and the like of each production process can also comprise product number information such as batch number, material number, model number and the like, and can also comprise production operator information, product qualification conditions and the like.
In the prior art, automatic generation of production logs is realized through a code scanning form and matching of related software and hardware. At present, a log system is usually designed in a main program, once the main program is abnormal and cannot normally run, the log system cannot normally record, so that a part of logs before the main program goes wrong cannot be recorded, and therefore the part of logs is lost, once abnormal product conditions occur in the lost part of logs, the tracking analysis of abnormal reasons of abnormal products is difficult to perform, and the production reliability is influenced.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: in order to solve the technical problem, a log management method and system are provided.
The technical scheme adopted by the invention for solving the technical problems is as follows: a log management method, comprising the steps of:
s1: when receiving external program call, writing the log information stored in the log database into a first address field of the shared memory;
s2: receiving new log information and writing the new log information into a second address field of the shared memory;
s3: comparing the log information in the first address field with the log information in the second address field;
s4: if the first address field does not have the log information in the second address field, storing the log information in the second address field into a log database so as to update the log information in the log database;
if the log information in the second address field exists in the first address field, the log information in the second address field is released.
Preferably, the log management method of the present invention,
when receiving an instruction of releasing the memory to empty the log information in the shared memory, executing the following steps:
s11: judging whether an external program for calling the log database is closed:
s12: if the external program is not closed, refusing to empty the log information in the shared memory;
if the external program is closed, executing S13;
s13: comparing the log information in the shared memory with the log information in the log database:
s14: if the log information in the shared memory does not exist in the log database, storing the log information in the log database to update the log information in the log database, and repeating S13;
and if the log information in the log database has all log information in the shared memory, releasing the memory and clearing the log information in the shared memory.
Preferably, the log management method of the present invention,
in step S14, step S11 is repeated again before the memory is released and the log information in the shared memory is cleared.
The present invention also provides a log management system, including:
the log collection module is used for writing the log information stored in the log database into a first address field of the shared memory when receiving external program calling;
the log information input module is used for receiving new log information and writing the new log information into a second address field of the shared memory;
the comparison module is used for comparing the log information in the first address field with the log information in the second address field and outputting a comparison result;
and the log updating module is used for storing the log information in the second address field into the log database to update the log information in the log database when the comparison result of the comparison module indicates that the log information in the second address field does not exist in the first address field.
Preferably, the log management system of the present invention further includes a security shutdown module, where the security shutdown module is configured to, when receiving a log management system shutdown instruction, first determine whether an external program calling the log management system is shutdown, refuse to shutdown the log management system if the external program is not shutdown, call a comparison module if the external program is shutdown, call the log update module and call the comparison module again when a comparison result of the comparison module is that log information in the second address field does not exist in the first address field, and only shut down the log management system when a comparison result of the comparison module is that log information in the second address field exists in the first address field.
Preferably, the log management system of the present invention,
in the safety closing module, whether the external program is closed is detected again before the log management system is closed, and the log management system is closed if the external program is still closed.
Preferably, the log management system of the present invention further includes an exception management module, where the exception management module is configured to store the log information in the shared memory to form a log backup database when an external program calling the log database is closed, compare the log backup database with the log database once when the external program is reopened and calls the log database, and store the log information that exists in the log backup database and does not exist in the log database into the log database.
Preferably, in the log management system of the present invention, the comparison module performs comparison at intervals.
Preferably, the log management system of the present invention further includes a memory release module, where the memory release module releases the log information in the second address field when the comparison result of the comparison module indicates that the log information in the second address field exists in the first address field.
Preferably, the log management system of the present invention further includes a log reading module, where the log reading module is configured to read all or part of log information in the shared memory; the log reading module can also search corresponding information in the log information in the first address field of the shared memory according to the input key words.
Preferably, the log management system of the present invention further includes a log display module, and the log display module is configured to transmit the log information read by the reading module to a display screen for display.
The invention has the beneficial effects that:
1. the log management method and the log management system are independent of a product production method and a product production main program, can be called by the main program, store log information into a shared memory when the main program is called, read and record the log information from the shared memory by a log reading module, display and analyze the log when necessary, and update the log information by a log updating module. When the main program is abnormal and can not run normally, the log management system records normally, and the problem of incomplete log record caused by the abnormal main program is solved.
2. According to the log management method and system, whether the external program is closed or not is confirmed before the log management system is closed and the internal memory is released, so that the log management system is prevented from being closed under the condition that the log information is updated, and when the external program is closed, the log information in the shared internal memory is compared with the log information in the log database to store the updated log information.
Drawings
The invention is further illustrated with reference to the following figures and examples.
FIG. 1 is a flow chart of the main steps of a log management method according to embodiment 1 of the present invention;
fig. 2 is a flowchart of an operation of the log management method according to embodiment 1 of the present invention before releasing the memory;
fig. 3 is a block diagram of the structure of a log management system of embodiment 2 of the present invention;
FIG. 4 is a block diagram of a process of a log update module of embodiment 2 of the present invention;
FIG. 5 is a block diagram of the processing of one embodiment of the secure shutdown module of the present invention;
FIG. 6 is a block diagram of the processing of another embodiment of the safety shutdown module of the present invention.
Detailed Description
The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic views illustrating only the basic structure of the present invention in a schematic manner, and thus show only the constitution related to the present invention.
Example 1
The present embodiment provides a log management method, as shown in fig. 1, including the following steps:
s1: when receiving external program call, writing the log information stored in the log database into a first address field of the shared memory;
s2: receiving new log information and writing the new log information into a second address field of the shared memory;
s3: comparing the log information in the first address field with the log information in the second address field;
s4: if the first address field does not have the log information in the second address field, storing the log information in the second address field into a log database so as to update the log information in the log database;
if the log information in the second address field exists in the first address field, the log information in the second address field is released.
The log management method of the embodiment does not depend on a product production control method, and when the log database is called, the log information is stored in the shared memory and is updated. The log management method independently prevents the problem of incomplete log record caused by other external program abnormity.
When an instruction to release log information in the shared memory for memory flushing is received (the instruction is usually because the whole program is about to be shut down), as shown in fig. 2, the following steps are performed:
s11: judging whether an external program for calling the log database is closed:
s12: if the external program is not closed, refusing to empty the log information in the shared memory;
if the external program is closed, executing S13;
s13: comparing the log information in the shared memory with the log information in the log database:
s14: if the log information in the shared memory does not exist in the log database, storing the log information in the log database to update the log information in the log database, and repeating S13;
and if the log information in the log database has all log information in the shared memory, releasing the memory and clearing the log information in the shared memory.
Before releasing the memory and clearing the log information in the shared memory, firstly confirming whether the external program is closed or not, preventing the log information from terminating the update of the log database under the condition of updating, and comparing the log information in the shared memory with the log information in the log database when the external program is closed, storing the updated log information, and by the operation, all the log information can be recorded in the log database, and preventing the data from being lost.
As an improved implementation method, in step S14, before releasing the memory and clearing the log information in the shared memory, step S11 is repeated again. By detecting whether the external program is closed again, the memory is prevented from being released under the condition that the external program is not closed due to short-time abnormal closing of the external program.
Example 2
The present embodiment provides a log management system, which has a structure as shown in fig. 3, and includes:
the log collection module is used for writing log information stored in a log database into a first address field of the shared memory when receiving external program calling, wherein the log database is stored in a storage medium, and the log information comprises but is not limited to information such as time, date, batch number, material number, model number, product state and the like;
the log information input module is used for receiving new log information and writing the new log information into a second address field of the shared memory, wherein the new log information is generated along with the production;
the comparison module is used for comparing the log information in the first address field with the log information in the second address field and outputting a comparison result, wherein the comparison result is as follows:
as a result, 1, log information within the second address field is not present in the first address field,
as a result, 2, log information within the second address field exists in the first address field;
the memory release module releases the log information in the second address field when the comparison result of the comparison module is 2; the memory release module is arranged, so that occupied memory can be cleaned in time, and the memory is prevented from being excessively consumed;
the log updating module is used for storing the log information in the second address field into the log database to update the log information in the log database when the comparison result of the comparison module is 1; the log update module typically performs the comparison at intervals (e.g., 1s, 10s, 30s, etc.), as shown in fig. 4;
the log reading module is used for reading all or part of log information in the shared memory; the log reading module can also search corresponding information in the log information in the shared memory according to the input key words; for example, retrieval may be by time or date;
the log display module is used for transmitting the log information read by the reading module to a display screen for displaying;
the log analysis module is used for analyzing the log information read by the reading module, such as statistical analysis according to time and date, statistical analysis according to model and batch number;
a safety closing module, which is used for judging whether the external program calling the log management system is closed or not when receiving an instruction for closing the log management system (the instruction is usually sent by clicking a mouse button by an operator and can also be sent by an external program), refusing to close the log management system if the external program is not closed, calling a comparison module if the external program is closed, comparing the log information in the shared memory with the log information in the log database, calling a log updating module if the comparison result is 1, storing the log information in the log database to update the log information in the log database, calling the comparison module again to compare the log information in the shared memory with the log information in the log database until the comparison result is 2, closing the log management system and releasing the memory, the flow is shown in fig. 5.
Before the log management system is closed, whether the external program is closed or not is confirmed, the log management system is prevented from being closed under the condition that the log information is updated, and when the external program is closed, the log information in the shared memory is compared with the log information in the log database to store the updated log information.
The improved implementation method for the safety shutdown module detects whether the external program is shut down again before the log management system is shut down, and shuts down the log management system to release the memory if the external program is still shut down.
By detecting whether the external program is closed again, the log management system is prevented from being closed under the condition that the external program is not closed due to short-time abnormal closing of the external program, and the flow is shown in fig. 6.
The log management system of the embodiment is independent of a main program for product production, when the main program runs, the main program is called by the main program, log information is stored in a shared memory when the main program is called, the log information is read out from the shared memory and recorded by a log reading module, if necessary, the log is displayed and analyzed, and the log information is updated by a log updating module. When the main program is abnormal and can not run normally, the log management system records normally, and the problem of incomplete log record caused by the abnormal main program is solved.
The log management system of the embodiment is independent of the production control main program, is provided with the safety closing module, and prevents the log information which is not stored from existing by confirming whether the external program calling the log management system is closed or not before the log management system is closed and carrying out information comparison for one time.
The log management system of this embodiment may further include an exception management module, where the exception management module is configured to store log information in the shared memory to form a log backup database when an external program that calls the log database is closed, compare the log backup database with the log database once when the external program is reopened and calls the log database, and store log information that exists in the log backup database and does not exist in the log database.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, devices, modules and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the embodiments can be implemented by hardware related to program instructions, and the program can be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic disk, hard disk, or optical disk. In light of the foregoing description of the preferred embodiment of the present invention, many modifications and variations will be apparent to those skilled in the art without departing from the spirit and scope of the invention. The technical scope of the present invention is not limited to the content of the specification, and must be determined according to the scope of the claims.

Claims (10)

1. A log management method, comprising the steps of:
s1: when receiving external program call, writing the log information stored in the log database into a first address field of the shared memory;
s2: receiving new log information and writing the new log information into a second address field of the shared memory;
s3: comparing the log information in the first address field with the log information in the second address field;
s4: if the first address field does not have the log information in the second address field, storing the log information in the second address field into a log database so as to update the log information in the log database;
if the log information in the second address field exists in the first address field, the log information in the second address field is released.
2. The log management method of claim 1,
when receiving an instruction of releasing the memory to empty the log information in the shared memory, executing the following steps:
s11: judging whether an external program for calling the log database is closed:
s12: if the external program is not closed, refusing to empty the log information in the shared memory;
if the external program is closed, executing S13;
s13: comparing the log information in the shared memory with the log information in the log database:
s14: if the log information in the shared memory does not exist in the log database, storing the log information in the log database to update the log information in the log database, and repeating S13;
and if the log information in the log database has all log information in the shared memory, releasing the memory and clearing the log information in the shared memory.
3. The log management method of claim 2,
in step S14, step S11 is repeated again before the memory is released and the log information in the shared memory is cleared.
4. A log management system, comprising:
the log collection module is used for writing the log information stored in the log database into a first address field of the shared memory when receiving external program calling;
the log information input module is used for receiving new log information and writing the new log information into a second address field of the shared memory;
the comparison module is used for comparing the log information in the first address field with the log information in the second address field and outputting a comparison result;
and the log updating module is used for storing the log information in the second address field into the log database to update the log information in the log database when the comparison result of the comparison module indicates that the log information in the second address field does not exist in the first address field.
5. The log management system according to claim 4, further comprising a security shutdown module, wherein the security shutdown module is configured to, when receiving a log management system shutdown instruction, first determine whether an external program that calls the log management system is shutdown, refuse to shutdown the log management system if the external program is not shutdown, call the comparison module if the external program is shutdown, call the log update module and call the comparison module again when a comparison result of the comparison module is that log information in the second address field does not exist in the first address field, and only shut down the log management system when a comparison result of the comparison module is that log information in the second address field exists in the first address field.
6. The log management system of claim 5,
in the safety closing module, whether the external program is closed is detected again before the log management system is closed, and the log management system is closed if the external program is still closed.
7. The log management system according to any one of claims 4 to 6, further comprising an exception management module, wherein the exception management module is configured to store log information in the shared memory to form a log backup database when an external program that calls the log database is closed, compare the log backup database with the log database once when the external program is reopened and calls the log database, and store log information that exists in the log backup database and does not exist in the log database.
8. The log management system of any of claims 4-6, wherein the comparison module performs the comparison at intervals.
9. The log management system according to any one of claims 4 to 6, further comprising a memory release module, wherein the memory release module releases the log information in the second address field when the comparison result of the comparison module indicates that the log information in the second address field exists in the first address field.
10. The log management system according to any one of claims 4 to 6, further comprising a log reading module and/or a log displaying module;
the log reading module is used for reading all or part of log information in the shared memory; the log reading module can also search corresponding information in log information in a first address field of the shared memory according to the input keyword;
and the log display module is used for transmitting the log information read by the reading module to a display screen for display.
CN201711376214.9A 2017-12-19 2017-12-19 Log management method and system Active CN108121789B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711376214.9A CN108121789B (en) 2017-12-19 2017-12-19 Log management method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711376214.9A CN108121789B (en) 2017-12-19 2017-12-19 Log management method and system

Publications (2)

Publication Number Publication Date
CN108121789A CN108121789A (en) 2018-06-05
CN108121789B true CN108121789B (en) 2020-06-30

Family

ID=62230364

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711376214.9A Active CN108121789B (en) 2017-12-19 2017-12-19 Log management method and system

Country Status (1)

Country Link
CN (1) CN108121789B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110515803B (en) * 2019-08-27 2021-04-13 联想(北京)有限公司 Processing method and device for log message and electronic equipment
CN111459894A (en) * 2020-03-24 2020-07-28 江苏核电有限公司 Nuclear power unit operation log recording system and recording method thereof
CN111489474A (en) * 2020-04-07 2020-08-04 科莱因(苏州)智能科技有限公司 Intelligent visual tracking permission system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103197988A (en) * 2012-01-05 2013-07-10 中国移动通信集团湖南有限公司 Data backup and recovery method, device and database system
CN103532754A (en) * 2013-10-12 2014-01-22 北京首信科技股份有限公司 System and method for high-speed memory and distributed type processing of massive logs
CN103942342A (en) * 2014-05-12 2014-07-23 中国人民大学 Memory database OLTP and OLAP concurrency query optimization method
US8868512B2 (en) * 2011-01-14 2014-10-21 Sap Se Logging scheme for column-oriented in-memory databases
CN104216802A (en) * 2014-09-25 2014-12-17 北京金山安全软件有限公司 Memory database recovery method and device
CN105335098A (en) * 2015-09-25 2016-02-17 华中科技大学 Storage-class memory based method for improving performance of log file system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8868512B2 (en) * 2011-01-14 2014-10-21 Sap Se Logging scheme for column-oriented in-memory databases
CN103197988A (en) * 2012-01-05 2013-07-10 中国移动通信集团湖南有限公司 Data backup and recovery method, device and database system
CN103532754A (en) * 2013-10-12 2014-01-22 北京首信科技股份有限公司 System and method for high-speed memory and distributed type processing of massive logs
CN103942342A (en) * 2014-05-12 2014-07-23 中国人民大学 Memory database OLTP and OLAP concurrency query optimization method
CN104216802A (en) * 2014-09-25 2014-12-17 北京金山安全软件有限公司 Memory database recovery method and device
CN105335098A (en) * 2015-09-25 2016-02-17 华中科技大学 Storage-class memory based method for improving performance of log file system

Also Published As

Publication number Publication date
CN108121789A (en) 2018-06-05

Similar Documents

Publication Publication Date Title
US20200379855A1 (en) Automation and optimization of data recovery after a ransomware attack
CN109240886B (en) Exception handling method, exception handling device, computer equipment and storage medium
CN108121789B (en) Log management method and system
CN102422261B (en) Exception raised notification
CN107209511B (en) Monitoring control device
US20170132525A1 (en) Method and system using machine learning techniques for checking data integrity in a data warehouse feed
US8738966B2 (en) Change management system and method
CN102629310A (en) System and method for protecting computer system from being infringed by activities of malicious objects
CN107357731B (en) Monitoring, analyzing and processing method for core dump problem generated by process
SG181959A1 (en) System event logging system
CN112799722A (en) Command recognition method, device, equipment and storage medium
EP3131041A1 (en) Testing of enterprise resource planning systems
CN111930703A (en) Automatic log file capturing method and device and computer equipment
CN116244138A (en) Method and device for identifying abnormal operation of application, electronic equipment and storage medium
CN103019906A (en) Method, device and system for popup information display
US7500145B2 (en) Anomaly-driven software switch to capture event responses and automate recovery
CN105553767A (en) Website backdoor file detection method and device
US11526162B2 (en) Method for detecting abnormal event and apparatus implementing the same method
JP2008015596A (en) Management server and repair program transmission method
JPWO2012153746A1 (en) Fraud detection system, fraud detection device, fraud detection method, and nonvolatile medium
CN112131090A (en) Business system performance monitoring method and device, equipment and medium
CN111949479A (en) Interactive system and method and equipment for determining index creation condition
CN111177241A (en) Data processing method, device and system, electronic equipment and storage medium thereof
CN110956552A (en) Insurance problem processing method, device, equipment and storage medium
CN112769729B (en) Server intrusion alarm method and system

Legal Events

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