WO2012106969A1 - 一种日志管理装置及方法 - Google Patents

一种日志管理装置及方法 Download PDF

Info

Publication number
WO2012106969A1
WO2012106969A1 PCT/CN2011/083884 CN2011083884W WO2012106969A1 WO 2012106969 A1 WO2012106969 A1 WO 2012106969A1 CN 2011083884 W CN2011083884 W CN 2011083884W WO 2012106969 A1 WO2012106969 A1 WO 2012106969A1
Authority
WO
WIPO (PCT)
Prior art keywords
log
record
log record
address
storage medium
Prior art date
Application number
PCT/CN2011/083884
Other languages
English (en)
French (fr)
Inventor
雷婷
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012106969A1 publication Critical patent/WO2012106969A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/04Processing captured monitoring data, e.g. for logfile generation

Definitions

  • the present invention relates to the field of embedded systems, and more particularly to a log management device and method in an embedded system. Background technique
  • logs recorded during system operation play an important role in user location system failure, early detection of warnings, and tracking of critical operations.
  • the embedded system is relatively lightweight. If you choose a professional database to manage the log, it will occupy a large storage space, and the support for the database will occupy the limited resources of the embedded system; if you select the log file to manage the log, it must be supported by the file system. If the file system is downloaded to memory during startup, the log file will not be saved after power failure.
  • a nonvolatile storage medium is selected in an embedded system to store log information; however, the storage space of the nonvolatile storage medium is limited, and the length of the log information is different, resulting in the nonvolatile storage medium being unable to save a large amount of logs. information. Summary of the invention
  • the main object of the present invention is to provide a log management apparatus and method, which can improve the capacity of a storage medium to store logs, improve the speed of reading and writing logs, and avoid loss of important information.
  • a log management device includes: a log recording module and a log management module; wherein, the log recording module is configured to compress the original log according to the conversion rule into a log record; invoke the log management module, and write according to the log record obtained by the log management module Into the address, the log will be Recording is written to the storage medium;
  • the log management module is configured to obtain the write address of the converted log record according to the log global information saved by the storage medium and the address range of the log record, and return to the log record module.
  • the log management module includes: a space allocation unit and an address calculation unit;
  • the space allocation unit is configured to divide log global information in the storage medium and an address range of the log record
  • the address calculation unit is configured to obtain a log record write address by using an address write calculation formula according to the log global information in the storage medium and the address range of the log record.
  • the log management module further includes: an overflow processing unit;
  • the overflow processing unit is configured to read the global information of the log in the storage medium, compare the number of the currently saved log records with the threshold of the number of the logs, and determine that the overflow threshold is processed when the threshold is reached; correspondingly, the log record
  • the module after writing the log record to the storage medium, notifies the overflow processing unit.
  • the log recording module includes: a log conversion unit and a log writing unit; wherein
  • a log conversion unit configured to convert the received log original text into a log record of a fixed length according to a conversion rule, and send the log record to the log writing unit;
  • the log writing unit is configured to write a log record to the storage medium according to the log record obtained by the log management module, and update the log global information.
  • the device further includes: a log output module
  • a log output module configured to read a log record according to the log record obtained by the log management module, read a log record corresponding to the address in the storage medium, and convert the log record into a log original text display;
  • the log management module is configured to obtain a log record to be read according to a log sequence number selected by the user, an address range of the log record in the storage medium, and an address reading calculation formula. Read the address.
  • the log output module includes: a log reading unit and a log inverse conversion unit;
  • a log reading unit configured to read a log record according to a log record obtained by the log management module, read a log record in a corresponding address in the storage medium, and send the log record to the log reverse conversion unit;
  • the log inverse conversion unit is configured to convert the log record into a log original text according to an inverse conversion rule.
  • a log management method includes: converting a log original compression into a log record, obtaining a write address of the converted log record according to the address range of the log record and the log global information; writing the log record according to the acquired log record write address Into the storage medium.
  • the converting the log original text into a log record is: converting the original log generated by the system into a fixed length log record according to a predetermined conversion rule.
  • the method further includes: comparing the number of currently saved log records in the storage medium with a threshold number, and determining that the number of currently saved log records reaches the number of records.
  • the overflow processing is performed according to a predetermined rule.
  • the method further includes: obtaining a log record read address according to a log sequence number selected by the user, an address range of the log record in the storage medium, and an address read calculation formula, and reading the log in the storage medium according to the address Record, and convert the log records to the original log according to the inverse conversion rules.
  • the original text of the log is compressed into a log record, and then written into the storage medium, thereby increasing the capacity of the storage medium to save the log; Log, avoid saving all the logs on the storage media before writing to the log.
  • the required log records can be read according to the log sequence number, which facilitates accurate and fast reading of the log, and avoids reading all the logs in the storage medium every time the log is read, thereby improving the read and write logs. Processing speed and the life of the storage medium. In addition, when the log record reaches the threshold, the overflow processing is performed to avoid the loss of important log records when the log record is full.
  • FIG. 1 is a schematic structural diagram of a log management apparatus according to the present invention.
  • FIG. 2 is a schematic diagram of storage contents of a storage medium in the present invention.
  • FIG. 3 is still another schematic diagram of the storage content of the storage medium in the present invention.
  • FIG. 4 is a schematic diagram of an implementation process of a log management method according to the present invention. detailed description
  • the basic idea of the present invention is: converting the original text of the log into a log record, obtaining the converted log record write address according to the address range of the log record and the log global information, and writing the address according to the log record, and converting the converted Log records are written to the storage medium.
  • the address range is an area for storing log records and log global information in a storage medium that is pre-divided and saved.
  • the log global information includes: a maximum log size (MaxNum), a current log capacity (TotalNum), and a start.
  • the MaxNum is a total number of log records that can be saved by the storage medium, and can be obtained by storing the space capacity of the log record and the length of the log record, and comparing the space capacity of the stored log record with the log record length.
  • the TotalNum is the number of currently saved log records, and the initial value is 0;
  • the address offset is used to identify the location of the log record in the storage medium, in units of the length of the log record, and the FirstOffset is the first log.
  • the record that is, the position of the log with the smallest log sequence number recorded in the storage medium, the initial value of FirstOffset is -1; the log sequence number is in accordance with the write order of the log record, and is sequentially incremented, and the number recorded by the log i is recorded. .
  • the log management device provided by the present invention, as shown in FIG. 1, includes: a log recording module 101 and a log management module 102;
  • the logging module 101 is configured to compress and convert the original log generated by the received system into a log record.
  • the log management module 102 is configured to write the log record to the storage medium according to the log record write address acquired by the log management module 102.
  • the log management module 102 is configured to obtain a log record write address according to the address range of the log record and the log global information saved by the storage medium, and return the log record to the log record module 101.
  • the management module 102 specifically includes a space allocation unit 1021 and an address calculation unit 1022;
  • the space allocation unit 1021 is configured to divide an address range of the storage log global information, and save the address range of the log record. The dividing is to pre-save the log global information and the address range of the log record.
  • part 201 of FIG. 2 is a global information area for saving logs
  • part 202 of FIG. 2 is a storage log record area
  • a total of log records are 1.
  • Log record 2 and log record 3 three log records, the serial number of the three log records are 1, 2, 3 respectively, the address offsets are 0, 1, 2; 4
  • the length of the log record is 8 bytes, the log record
  • the space capacity is 4096 bytes, then MaxNum is 512, TotalNum is 3, StartSeq is 1, EndSeq is 3, and FirstOffset is 0.
  • the address calculation unit 1022 is configured to obtain an address offset of the log record in the storage medium according to the log global information and the address write calculation formula in the storage medium, and then obtain the log in the storage medium according to the address range of the locally saved log record. Record the write address, that is, the address corresponding to the address offset;
  • the specific process of obtaining the log record write address in the storage medium is: obtaining the address offset of the log record to be written by using the log global information and the address write calculation formula, Then, by multiplying the address offset by the log record length, and adding the start address of the log record, the address in the storage medium corresponding to the address offset is obtained, that is, the log record write address; for example : Assume that the address offset to be written is A, the log record length is B, and the start address of the save log record is C. The log record write address in the storage medium is: A*B+C.
  • the address writing calculation formula is:
  • the log management module 102 further includes: an overflow processing unit 1023, configured to read global log information in the storage medium, compare TotalNum with a locally saved number threshold, and determine that the TotalNum reaches a threshold, according to a predetermined rule. Overfill processing; when TotalNum does not reach the threshold, it will not be processed;
  • the number of thresholds may be set as needed, but may not be greater than MaxNum; the predetermined rule may be to display an alarm, prompt the user that the log record has reached the threshold, need to be cleaned, or clean the log record according to the set method. ;
  • the logging module 101 is configured to notify the overflow processing unit 1023 after writing the log record.
  • the log recording module 101 specifically includes: a log conversion unit 1011 and a log writing unit 1012;
  • the log conversion unit 1011 is configured to receive a log original of the system, and compress the original log of the log into a fixed-length log record according to a predetermined conversion rule, and send the log to the log writing unit 1012.
  • the conversion rule may be compressed.
  • the encryption algorithm converts the log compression into a fixed-length ciphertext, such as a message digest algorithm (MD5); or, pre-sets a mapping relationship between the original log and the log record, and performs compression conversion according to the mapping relationship.
  • MD5 message digest algorithm
  • the log writing unit 1012 is configured to write the log record to the storage medium according to the log record write address acquired by the log management module 102, and further use to update the log in the storage medium. Bureau information
  • the update is to add 1 to TotalNum in the log global information, and to add 1 to EndSeq, that is, the log sequence number after the current log record is written, and the log sequence number is written to the storage medium by the log writing unit 1012. The number of the log record.
  • the log writing unit 1012 is further configured to: when the storage log space is full in the storage medium, the log record to be written overwrites the earliest written log record, that is, the log record with the smallest serial number, and simultaneously updates the log global information;
  • the update is to add EndSeq to 1 , change StartSeq to the sequence number corresponding to the log record with the smallest serial number, and change FirstOffset to the address offset of the log record corresponding to StartSeq.
  • the device further includes: a log output module 103, configured to invoke the log management module 102, read the log record in the storage medium according to the log record read address acquired by the log management module 102, and convert the log file to the user;
  • the call contains a log sequence selected by the user, and the log management module 102 is further configured to obtain a log offset of the log record to be read according to the log sequence number and the address read calculation formula selected by the user, and then according to the log record.
  • a log output module 103 configured to invoke the log management module 102, read the log record in the storage medium according to the log record read address acquired by the log management module 102, and convert the log file to the user
  • the call contains a log sequence selected by the user
  • the log management module 102 is further configured to obtain a log offset of the log record to be read according to the log sequence number and the address read calculation formula selected by the user, and then according to the log record.
  • In the address range in the storage medium obtain the log record read address in the storage medium, and return
  • the obtaining the log record read address in the storage medium is specifically: obtaining an address offset of the log record to be read according to formulas (2) and Y, and starting address according to the address offset and the log record in the storage medium Obtain the address of the log to be read on the storage medium. For example, if the address offset of the log record to be read is D, the start address of the log record is C, and the log length is B, then read The address of the log recorded in the storage medium is: B*D+C;
  • the log output module 103 specifically includes: a log reading unit 1031 and a log inverse conversion unit 1032;
  • the log reading unit 1031 is configured to invoke the log management module 102, and according to the log record read address obtained by the log management module 102, read the log record in the storage medium, and send it to the log reverse conversion unit 1032;
  • the log inverse conversion unit 1032 is configured to convert the log record into a log original text according to an inverse conversion rule, where the inverse conversion rule is an inverse process of the conversion rule, and restore the log record to a log original text.
  • the present invention also provides a log management method. As shown in FIG. 4, the specific steps are as follows:
  • Step 401 Convert the original log of the system into a log record.
  • the log management device reads the original text of the log generated by the system, and converts the log compression into a log record of the same length according to the conversion rule, and the conversion may use a compression encryption algorithm to convert the log into a log record of a certain length, for example, using MD5. Algorithm; or pre-set the mapping relationship between the original log and the log record, and convert according to the mapping relationship.
  • a compression encryption algorithm to convert the log into a log record of a certain length, for example, using MD5. Algorithm; or pre-set the mapping relationship between the original log and the log record, and convert according to the mapping relationship.
  • the log management device acquires the address offset of the log record to be written into the storage medium according to the formula (1) and the log global information in the storage medium, and then obtains the address offset according to the address range recorded in the storage medium by the log.
  • the address in the storage medium corresponding to the shift amount, that is, the log record write address, the specific process of writing the log record address is: obtaining the address offset of the log record to be written by using the log global information and the address writing calculation formula
  • the shift amount is then multiplied by the log offset by the address offset, plus the start address of the save log record, which is the log record write address.
  • Step 403 Write the log record to the storage medium according to the obtained log record write address.
  • the log management device writes the log record to the storage medium according to the calculated log record write address, and updates the log global information, the update is to add TotalNum to 1 and add EndSeq to 1; taking the content described in FIG. 2 as an example.
  • the TotalNum is compared with the locally saved number threshold, and when the TotalNum reaches the threshold, the overflow management process is performed according to a predetermined rule, and the overflow processing may be to display an alarm to the user. , remind users to clean the storage media. If the user does not clean the storage medium, the log management device writes the log record, and finds that the save log record space is full. According to the calculated log record write address, the log record covers the log record first written to the storage medium. At the same time, the log global information is updated. The update is to increase EndSeq by 1, change StartSeq to the serial number corresponding to the log record with the smallest serial number, and change FirstOffset to the address offset of the log record corresponding to StartSeq.
  • the log management device reads the log record in the storage medium, according to the log record serial number selected by the user and the formula (1), the address offset of the log record to be read is obtained. Then, according to the address range of the log record, the log record read address in the storage medium is obtained, the log record in the address in the storage medium is read, and the log record is converted into the log original text according to the inverse conversion rule, and displayed to the user.
  • the conversion is a reverse process of converting the original text of the log into a log record, for example, using an MD5 decryption algorithm, or converting the log record into a log original according to a preset mapping relationship.

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种日志管理装置,该装置包括:日志记录模块,用于将日志原文,根据转换规则压缩转换为日志记录,调用日志管理模块;根据日志管理模块获取的日志记录写入地址,将日志记录写入存储介质;日志管理模块,用于根据存储介质保存的日志全局信息以及日志记录的地址范围,获取日志记录写入地址,返回给日志记录模块。本发明还公开了一种日志管理的方法,采用本发明所述的装置及方法,提高了存储介质保存日志的容量,以及读写日志的处理速度,且避免重要日志丢失。

Description

一种日志管理装置及方法 技术领域
本发明涉及嵌入式系统领域, 特别是指嵌入式系统中一种日志管理装 置及方法。 背景技术
在通信和计算机信息处理相关产品中, 系统运行过程中记录的日志对 于用户定位系统故障、 及早发现警告和跟踪关键操作有着重要的作用。 嵌 入式系统比较轻巧, 如果选择专业的数据库来管理日志, 将占用较大存储 空间, 并且对数据库的支持将占用嵌入式系统有限的资源; 如果选择日志 文件来管理日志, 则必须由文件系统支持, 如果文件系统在启动时是下载 到内存中运行的, 掉电后日志文件将无法保存。
一般的, 在嵌入式系统中选择非易失存储介质来保存日志信息; 但是, 非易失存储介质的存储空间有限, 并且日志信息的长短不一, 导致非易失 存储介质无法保存大量的日志信息。 发明内容
有鉴于此, 本发明的主要目的在于提供一种日志管理装置及方法, 能 提高存储介质保存日志的容量, 提升日志的读写速度, 且能避免重要曰志 丟失。
为解决上述技术问题, 本发明的技术方案是这样实现的:
一种日志管理装置, 包括: 日志记录模块、 日志管理模块; 其中, 日志记录模块, 用于将日志原文根据转换规则压缩转换为日志记录; 调用日志管理模块, 根据日志管理模块获取的日志记录写入地址, 将日志 记录写入存储介质;
日志管理模块, 用于根据存储介质保存的日志全局信息以及日志记录 的地址范围, 获取转换后日志记录的写入地址, 返回给日志记录模块。
上述方案中, 所述日志管理模块包括: 空间分配单元、 地址计算单元; 其中,
所述空间分配单元, 用于划分存储介质中日志全局信息以及日志记录 的地址范围;
所述地址计算单元, 用于根据存储介质中的日志全局信息、 日志记录 的地址范围, 通过地址写入计算公式, 获取日志记录写入地址。
其中, 所述日志管理模块进一步包括: 溢满处理单元;
溢满处理单元, 用于读取存储介质中的日志全局信息, 将当前已保存 的日志记录条数同条数阈值比较, 确定达到条数阈值时进行溢满处理; 相应的, 所述日志记录模块, 用于将日志记录写入存储介质后, 通知 溢满处理单元。
上述方案中, 所述日志记录模块包括: 日志转换单元、 日志写入单元; 其中,
日志转换单元, 用于将接收的日志原文, 根据转换规则转换为固定长 度的日志记录, 发送给日志写入单元;
日志写入单元, 用于根据日志管理模块获取的日志记录写入地址, 将 日志记录写入存储介质, 并更新日志全局信息。
其中, 所述装置进一步包括: 日志输出模块;
日志输出模块, 用于根据日志管理模块获取的日志记录读取地址, 读 取存储介质中所述地址对应的日志记录, 转换为日志原文显示;
相应的, 日志管理模块, 用于根据用户选择的日志序列号、 日志记录 在存储介质中的地址范围以及地址读取计算公式, 获取要读取的日志记录 读取地址。
上述方案中, 所述日志输出模块包括: 日志读取单元、 日志反转换单 元; 其中,
日志读取单元, 用于根据日志管理模块获取的日志记录读取地址, 读 取存储介质中相应地址中的日志记录, 发送给日志反转换单元;
日志反转换单元, 用于根据反转换规则, 将日志记录转换为日志原文。 一种日志管理方法, 包括: 将日志原文压缩转换为日志记录, 根据日 志记录的地址范围以及日志全局信息获取转换后日志记录的写入地址; 根 据获取的日志记录写入地址, 将日志记录写入存储介质。
其中, 所述将日志原文压缩转换为日志记录为: 根据预定的转换规则 将系统产生的日志原文转换为固定长度的日志记录。
其中, 所述将日志记录写入存储介质之后, 所述方法进一步包括: 将 存储介质中的当前已保存的日志记录条数同条数阈值比较, 确定当前已保 存的日志记录条数达到条数阈值时, 根据预定规则进行溢满处理。
其中, 所述方法进一步包括: 根据用户选择的日志序列号、 日志记录 在存储介质中的地址范围以及地址读取计算公式, 获取日志记录读取地址, 根据所述地址读取存储介质中的日志记录, 并根据反转换规则将日志记录 转换为日志原文。
由此可见, 采用本发明所述的日志管理装置及方法, 将日志原文压缩 转换为日志记录, 再写入到存储介质中, 提高了存储介质保存日志的容量; 按照日志记录写入地址写入日志, 避免写入日志时将存储介质上的日志全 部刷新才可写入。
进一步的, 可根据日志序列号读取需要的日志记录, 有利于准确快速 读取日志, 避免了每次读取日志时, 将存储介质中的日志全部读取一遍, 从而提高了读写日志的处理速度以及存储介质的使用期限。 另外, 在日志记录达到条数阈值时, 进行溢满处理, 可避免日志记录 满时, 重要日志记录丟失。 附图说明
图 1为本发明日志管理装置的组成结构示意图;
图 2为本发明中存储介质保存内容示意图;
图 3为本发明中存储介质保存内容又一示意图
图 4为本发明日志管理方法的实现流程示意图。 具体实施方式
本发明的基本思想是: 将日志原文压缩转换为日志记录, 根据日志记 录的地址范围及日志全局信息, 获取转换后的日志记录写入地址, 根据日 志记录写入地址, 将所述转换后的日志记录写入存储介质。
其中, 所述地址范围为预先划分并保存的存储介质中用于保存日志记 录以及日志全局信息的区域; 所述日志全局信息包括: 日志最大容量 ( MaxNum )、 当前日志容量( TotalNum )、 起始日志序列号( StartSeq )、 终 止曰志序列号 ( EndSeq )、 首条日志记录的地址偏移量( FirstOffset )。
这里, 所述 MaxNum为存储介质所能保存的日志记录的总数量, 可以 通过存储日志记录的空间容量以及日志记录的长度获取, 将存储日志记录 的空间容量与日志记录长度相比, 即可获取 MaxNum; 所述 TotalNum为当 前已保存的日志记录条数, 初始值为 0; 地址偏移量用于标识日志记录在存 储介质中的位置, 以日志记录的长度为单位, 所述 FirstOffset为首条日志记 录、也就是日志序列号最小的一条日志记录在存储介质中的位置, FirstOffset 的初始值为 -1 ; 所述日志序列号为根据日志记录写入顺序, 依次递增, 对日 志 i己录的编号。
下面通过附图与具体实施例来对本发明进行详细说明。 本发明提供的日志管理装置, 如图 1 所示, 该装置包括: 日志记录模 块 101和日志管理模块 102; 其中,
日志记录模块 101 , 用于将接收的系统产生的日志原文,压缩转换为日 志记录; 调用日志管理模块 102,根据日志管理模块 102获取的日志记录写 入地址, 将日志记录写入存储介质;
日志管理模块 102 ,用于根据日志记录的地址范围以及存储介质保存的 日志全局信息, 获取日志记录写入地址, 返回给日志记录模块 101。
曰志管理模块 102具体包括:空间分配单元 1021和地址计算单元 1022; 其中,
空间分配单元 1021 , 用于划分存储介质中, 保存日志全局信息的地址 范围以及保存日志记录的地址范围; 所述划分为预先保存所述日志全局信 息以及日志记录的地址范围。
下面通过一个具体的例子, 对存储介质中保存内容进行说明, 如图 2 所示, 图 2中 201部分为保存日志全局信息区域, 图 2中 202部分为保存 日志记录区域,共有日志记录 1、日志记录 2以及日志记录 3三条日志记录, 三条日志记录的序列号分别为 1、 2、 3 , 地址偏移量分别为 0、 1、 2; 4叚设 日志记录的长度为 8 bytes, 日志记录空间容量为 4096 bytes , 那么此时 MaxNum为 512, TotalNum为 3 , StartSeq为 1 , EndSeq为 3 , FirstOffset 为 0。
地址计算单元 1022, 用于根据存储介质中的日志全局信息以及地址写 入计算公式, 获取存储介质中日志记录的地址偏移量, 然后根据本地保存 的日志记录的地址范围, 获取存储介质中日志记录写入地址, 也就是地址 偏移量对应的地址;
这里, 所述获取存储介质中日志记录写入地址的具体过程为: 通过日 志全局信息以及地址写入计算公式, 获取要写入的日志记录的地址偏移量, 然后通过所述地址偏移量与日志记录长度相乘, 再加上保存日志记录的起 始地址, 即可获取地址偏移量对应的存储介质中的地址, 也就是日志记录 写入地址; 例如: 假设要写入的地址偏移量为 A, 日志记录长度为 B, 保存 日志记录的起始地址为 C, 则存储介质中的日志记录写入地址为: A*B+C。 其中, 所述地址写入计算公式为:
( EndSeq+1-StartSeq ) %MaxNum+FirstOffset ( 1 );
其中 "%" 为取余。
所述日志管理模块 102进一步包括: 溢满处理单元 1023 , 用于读取存 储介质中的日志全局信息, 将 TotalNum同本地保存的条数阈值比较, 确定 TotalNum达到条数阈值时, 按照预定规则进行溢满处理; TotalNum未达到 条数阈值时, 不做处理;
这里, 所述条数阈值可根据需要设定, 但不可大于 MaxNum; 所述预 定规则可以是显示告警, 提示用户日志记录已达到阈值, 需要清理, 或者 根据设定的方法对日志记录进行清理等;
相应的, 日志记录模块 101 , 用于写入日志记录后, 通知溢满处理单元 1023。
所述日志记录模块 101具体包括: 日志转换单元 1011和日志写入单元 1012; 其中,
日志转换单元 1011 , 用于接收系统的日志原文, 根据预定的转换规则, 将日志原文压缩转换为固定长度的日志记录,并发送给日志写入单元 1012; 其中, 所述转换规则, 可以采用压缩加密算法, 将日志压缩转换为固 定长度的密文, 例如消息摘要算法(MD5 ); 或者, 预先设定日志原文与日 志记录的映射关系, 根据映射关系进行压缩转换。
日志写入单元 1012 , 用于根据日志管理模块 102获取的日志记录写入 地址, 将日志记录写入存储介质, 并进一步用于更新存储介质中的日志全 局信息;
其中,所述更新为将日志全局信息中的 TotalNum加 1 ,将 EndSeq加 1 , 即为当前日志记录写入后的日志序列号, 所述日志序列号为日志写入单元 1012写入存储介质的日志记录的编号。
日志写入单元 1012进一步用于,存储介质中存储日志记录空间已满时, 将要写入的日志记录覆盖最早写入的日志记录、 即序列号最小的日志记录, 同时更新日志全局信息;
其中, 所述更新为将 EndSeq加 1 , 将 StartSeq变更为序列号最小的日 志记录所对应的序列号,将 FirstOffset变更为 StartSeq对应的日志记录的地 址偏移量。
下面通过一个具体示例来说明, 图 2所示的日志记录存储空间存储满 后, 又写入两条日志记录后的情况, 如图 3 所示, 日志记录存储区域共存 储了 512条日志记录, 此时日志全局信息为 MaxNum为 512 , TotalNum为 512 , StartSeq为 3 , EndSeq为 514, FirstOffset为 2。
上述装置进一步包括: 日志输出模块 103 ,用于调用日志管理模块 102, 根据日志管理模块 102获取的日志记录读取地址, 读取存储介质中的日志 记录, 转换为日志原文显示给用户; 所述调用中包含用户选择的日志序列 相应的, 日志管理模块 102,还用于根据用户选择的日志序列号以及地 址读取计算公式, 获取要读取的日志记录的地址偏移量, 然后根据日志记 录在存储介质中的地址范围, 获取存储介质中日志记录读取地址, 返回给 日志输出模块 103;
这里, 所述地址读取计算公式为:
( Y-StartSeq+FirstOffset ) %MaxNum ( 2 );
其中, Y为要读的日志序列号, "%" 为取余; 所述获取存储介质中日志记录读取地址具体为: 根据公式( 2 )及 Y获 取要读取的日志记录的地址偏移量, 根据地址偏移量及日志记录在存储介 质中的起始地址, 获取要读取的日志记录在存储介质中的地址, 例如, 假 设要读取的日志记录的地址偏移量为 D, 日志记录的起始地址为 C、 日志长 度为 B, 则要读取的日志记录在存储介质中的地址为: B*D+C;
所述日志输出模块 103具体包括: 日志读取单元 1031和日志反转换单 元 1032; 其中,
日志读取单元 1031 , 用于调用日志管理模块 102, 根据日志管理模块 102获取的日志记录读取地址,读取存储介质中的日志记录,发给日志反转 换单元 1032;
日志反转换单元 1032, 用于根据反转换规则, 将日志记录转换为日志 原文, 所述反转换规则为转换规则的逆过程, 将日志记录还原为日志原文。
基于上述装置, 本发明还提供了一种日志管理方法, 如图 4所示, 具 体步驟如下:
步驟 401、 将系统的日志原文压缩转换为日志记录;
这里, 日志管理装置读取系统产生的日志原文, 根据转换规则, 将日 志压缩转换为长度一致的日志记录, 所述转换可以采用压缩加密算法, 将 日志转换为一定长度的日志记录, 例如采用 MD5算法; 或者预先设定日志 原文与日志记录的映射关系, 根据映射关系进行转换。
以下面一条日志原文为例: 2009-3-30 10:17:36 A.info: LIP detected on host port 2; 将时间 2009-3-30 10:17:36转换为 4个字节 time— t数据结构: CO 2B DO 49, 所述时间的映射关系, 可以根据 C语言的转换函数获取, 根 据预设的事件标识,将 A.info: LIP detected on host port转换与之对应的事件 标识, 支设为 05 30,再加上端口参数 2,则转换后的日志记录为: C0 2B D0 49 05 30 02 00。 步驟 402、 获取存储介质中转换后日志记录的写入地址;
这里, 日志管理装置根据公式( 1 ) 以及存储介质中的日志全局信息, 获取要写入存储介质的日志记录的地址偏移量, 然后再根据日志记录在存 储介质中的地址范围, 获取地址偏移量对应的存储介质中的地址, 也就是 日志记录写入地址, 所述日志记录写入地址具体过程为: 通过日志全局信 息以及地址写入计算公式, 获取要写入的日志记录的地址偏移量, 然后通 过所述地址偏移量与日志记录长度相乘, 加上保存日志记录的起始地址, 即为日志记录写入地址。
步驟 403、 根据获取的日志记录写入地址将日志记录写入存储介质。 这里, 日志管理装置根据计算的日志记录写入地址将日志记录写入到 存储介质, 并更新日志全局信息, 所述更新为将 TotalNum加 1 , 将 EndSeq 加 1 ; 以图 2所述内容为例,在当前图 2对应的存储介质保存的内容中写入 一条日志记录, 根据公式( 1 )计算得到的地址为: ( 3+1-1 ) %512+0=3 , 则 要写入的日志记录的地址偏移量为 3 ,然后将日志记录写入地址偏移量 3对 应的存储介质中的地址, 同时将 TotalNum更新为 4 , 将 EndSeq更新为 4。
日志管理装置将日志记录写入存储介质后, 将 TotalNum与本地保存的 条数阈值比较, 确定 TotalNum达到条数阈值时, 根据预定规则进行溢满处 理, 所述溢满处理可以是向用户显示告警, 提醒用户清理存储介质。 若用 户没有对存储介质进行清理, 日志管理装置写入日志记录时, 发现保存日 志记录空间已满, 根据计算得到的日志记录写入地址, 将日志记录覆盖最 先写入存储介质的日志记录,同时更新日志全局信息,所述更新为将 EndSeq 加 1 , 将 StartSeq 变更为序列号最小的日志记录所对应的序列号, 将 FirstOffset变更为 StartSeq对应的日志记录的地址偏移量。
进一步的, 日志管理装置读取存储介质中的日志记录时, 根据用户选 择的日志记录序列号以及公式( 1 ), 获取要读取的日志记录的地址偏移量, 然后根据日志记录的地址范围, 获取存储介质中日志记录读取地址, 读取 存储介质中所述地址中的日志记录, 并将日志记录根据反转换规则转换为 日志原文, 显示给用户。 所述转换是将日志原文转换为日志记录的反过程, 例如利用 MD5解密算法, 或者, 根据预设的映射关系, 将日志记录转换为 日志原文。
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的保 护范围。

Claims

权利要求书
1、 一种日志管理装置, 其特征在于, 该装置包括: 日志记录模块、 日 志管理模块; 其中,
日志记录模块, 用于将日志原文根据转换规则压缩转换为日志记录; 调用日志管理模块, 根据日志管理模块获取的日志记录写入地址, 将日志 记录写入存储介质;
日志管理模块, 用于根据存储介质保存的日志全局信息以及日志记录 的地址范围, 获取转换后日志记录的写入地址, 返回给日志记录模块。
2、根据权利要求 1所述的装置, 其特征在于, 所述日志管理模块包括: 空间分配单元、 地址计算单元; 其中,
所述空间分配单元, 用于划分存储介质中日志全局信息以及日志记录 的地址范围;
所述地址计算单元, 用于根据存储介质中的日志全局信息、 日志记录 的地址范围, 通过地址写入计算公式, 获取日志记录写入地址。
3、 根据权利要求 2所述的装置, 其特征在于, 所述日志管理模块进一 步包括: 溢满处理单元;
溢满处理单元, 用于读取存储介质中的日志全局信息, 将当前已保存 的日志记录条数同条数阈值比较, 确定达到条数阈值时进行溢满处理; 相应的, 所述日志记录模块, 用于将日志记录写入存储介质后, 通知 溢满处理单元。
4、根据权利要求 1所述的装置,其特征在于, 所述日志记录模块包括: 曰志转换单元、 日志写入单元; 其中,
日志转换单元, 用于将接收的日志原文, 根据转换规则转换为固定长 度的日志记录, 发送给日志写入单元;
日志写入单元, 用于根据日志管理模块获取的日志记录写入地址, 将 日志记录写入存储介质, 并更新日志全局信息。
5、 根据权利要求 1至 4任一项所述的装置, 其特征在于, 该装置进一 步包括: 日志输出模块;
日志输出模块, 用于根据日志管理模块获取的日志记录读取地址, 读 取存储介质中所述地址对应的日志记录, 转换为日志原文显示;
相应的, 日志管理模块, 用于根据用户选择的日志序列号、 日志记录 在存储介质中的地址范围以及地址读取计算公式, 获取要读取的日志记录 读取地址。
6、根据权利要求 5所述的装置,其特征在于, 所述日志输出模块包括: 曰志读取单元、 日志反转换单元; 其中,
日志读取单元, 用于根据日志管理模块获取的日志记录读取地址, 读 取存储介质中相应地址中的日志记录, 发送给日志反转换单元;
日志反转换单元, 用于根据反转换规则, 将日志记录转换为日志原文。
7、 一种日志管理方法, 其特征在于, 该方法包括:
将日志原文压缩转换为日志记录, 根据日志记录的地址范围以及日志 全局信息获取转换后日志记录的写入地址;
根据获取的日志记录写入地址, 将日志记录写入存储介质。
8、 根据权利要求 7所述的方法, 其特征在于, 所述将日志原文压缩转 换为日志记录为:
根据预定的转换规则将系统产生的日志原文转换为固定长度的日志记 录。
9、 根据权利要求 7所述的方法, 其特征在于, 所述将日志记录写入存 储介质之后, 该方法进一步包括:
将存储介质中的当前已保存的日志记录条数同条数阈值比较, 确定当 前已保存的日志记录条数达到条数阈值时, 根据预定规则进行溢满处理。
10、 根据权利要求 7至 9任一所述的方法, 其特征在于, 该方法进一 步包括:
根据用户选择的日志序列号、 日志记录在存储介质中的地址范围以及 地址读取计算公式, 获取日志记录读取地址, 根据所述地址读取存储介质 中的日志记录, 并根据反转换规则将日志记录转换为日志原文。
PCT/CN2011/083884 2011-02-09 2011-12-13 一种日志管理装置及方法 WO2012106969A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110034924.X 2011-02-09
CN201110034924.XA CN102158349B (zh) 2011-02-09 2011-02-09 一种日志管理装置及方法

Publications (1)

Publication Number Publication Date
WO2012106969A1 true WO2012106969A1 (zh) 2012-08-16

Family

ID=44439550

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/083884 WO2012106969A1 (zh) 2011-02-09 2011-12-13 一种日志管理装置及方法

Country Status (2)

Country Link
CN (1) CN102158349B (zh)
WO (1) WO2012106969A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024008460A1 (de) 2022-07-05 2024-01-11 Mercedes-Benz Group AG Verfahren zum verarbeiten von logdateien, datenverarbeitungssystem und fahrzeug

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102158349B (zh) * 2011-02-09 2016-03-30 中兴通讯股份有限公司 一种日志管理装置及方法
CN103270499B (zh) * 2011-12-21 2016-10-05 华为技术有限公司 日志存储方法及系统
CN103368756B (zh) * 2012-03-29 2016-08-03 福建星网视易信息系统有限公司 用于监控嵌入式系统运行的日志的管理系统
CN104717086B (zh) * 2013-12-16 2018-07-31 华为技术有限公司 抑制日志风暴的方法及装置
CN103927251B (zh) * 2014-03-18 2017-02-01 烽火通信科技股份有限公司 一种嵌入式系统的日志管理方法
CN105700996A (zh) * 2014-11-27 2016-06-22 迈普通信技术股份有限公司 一种日志的输出方法及装置
CN106301845A (zh) * 2015-05-30 2017-01-04 四川泰瑞创通讯技术股份有限公司 交换机日志记录模块
CN106484728B (zh) * 2015-08-31 2019-08-30 联芯科技有限公司 日志数据的生成方法、解析方法、生成装置及解析装置
CN106445837B (zh) * 2016-10-12 2020-01-17 许继集团有限公司 一种嵌入式装置历史记录存储与加载管理实现方法及装置
CN107273460A (zh) * 2017-06-01 2017-10-20 郑州云海信息技术有限公司 一种存储产品系统日志的存储方法
CN112286462A (zh) * 2020-10-30 2021-01-29 广东科徕尼智能科技有限公司 智能锁的日志管理方法、系统、智能锁及存储装置
CN112559458B (zh) * 2020-12-11 2021-11-30 深圳金信诺高新技术股份有限公司 一种缩减日志大小的方法及系统
CN114973500B (zh) * 2021-02-26 2023-12-22 深圳怡化电脑股份有限公司 金融终端机芯日志传输方法、装置、电子设备和介质
CN113177033B (zh) * 2021-03-31 2022-12-16 新华三信息安全技术有限公司 一种日志数据存储方法、装置、电子设备和介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1425986A (zh) * 2003-01-17 2003-06-25 清华大学 自动压缩/解压缩文件系统及其压缩算法
US20040103399A1 (en) * 2002-11-22 2004-05-27 Manisha Agarwala Data trace compression map
CN101162441A (zh) * 2007-11-09 2008-04-16 华为技术有限公司 数据的存取装置和方法
CN101183801A (zh) * 2007-12-07 2008-05-21 杭州华三通信技术有限公司 一种掉电保护方法、系统和装置
CN102158349A (zh) * 2011-02-09 2011-08-17 中兴通讯股份有限公司 一种日志管理装置及方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1536788B (zh) * 2003-04-11 2010-04-28 华为技术有限公司 日志保留系统和方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040103399A1 (en) * 2002-11-22 2004-05-27 Manisha Agarwala Data trace compression map
CN1425986A (zh) * 2003-01-17 2003-06-25 清华大学 自动压缩/解压缩文件系统及其压缩算法
CN101162441A (zh) * 2007-11-09 2008-04-16 华为技术有限公司 数据的存取装置和方法
CN101183801A (zh) * 2007-12-07 2008-05-21 杭州华三通信技术有限公司 一种掉电保护方法、系统和装置
CN102158349A (zh) * 2011-02-09 2011-08-17 中兴通讯股份有限公司 一种日志管理装置及方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024008460A1 (de) 2022-07-05 2024-01-11 Mercedes-Benz Group AG Verfahren zum verarbeiten von logdateien, datenverarbeitungssystem und fahrzeug
DE102022002450A1 (de) 2022-07-05 2024-01-11 Mercedes-Benz Group AG Verfahren zum Verarbeiten von Logdateien, Datenverarbeitungssystem und Fahrzeug

Also Published As

Publication number Publication date
CN102158349A (zh) 2011-08-17
CN102158349B (zh) 2016-03-30

Similar Documents

Publication Publication Date Title
WO2012106969A1 (zh) 一种日志管理装置及方法
CN108733344B (zh) 数据读写方法、装置以及环形队列
JP5963314B2 (ja) テープ媒体上での総シーク時間を減らすための方法、システム及びプログラム
US9015695B2 (en) Information processing apparatus and information processing method
JP2014506708A5 (zh)
TW201539187A (zh) 快閃記憶體之壓縮、讀取方法及應用其方法的裝置
US20160034201A1 (en) Managing de-duplication using estimated benefits
CN109800181B (zh) 一种基于磁盘的数据写入方法、数据写入装置及终端设备
JP6020291B2 (ja) 通信監視方法、通信監視装置、通信監視プログラム
US20190287571A1 (en) Method and device for playing video
US9910857B2 (en) Data management
US10803109B2 (en) Method and device for reading and writing video data in NAS device
JP2012123770A (ja) 車両記録装置とイメージ記録方法
CN105304140A (zh) 电子设备的存储器性能的测试方法及装置
CN104408126B (zh) 一种数据库的持久化写入方法、装置和系统
US20140258247A1 (en) Electronic apparatus for data access and data access method therefor
CN105260266B (zh) 一种快照卷写方法及依赖快照系统
CN112181275A (zh) 一种数据处理器及数据处理方法
JP7063445B2 (ja) 障害情報処理プログラム、コンピュータ、障害通知方法、コンピュータシステム
CN110019347A (zh) 一种区块链的数据处理方法、装置及终端设备
US10705738B2 (en) Method, apparatus, storage medium, and terminal for optimizing memory card performance
US20140317354A1 (en) Electronic device, data caching system and method
CN104810037A (zh) 数据记录装置
US20130218851A1 (en) Storage system, data management device, method and program
TWI387873B (zh) 反相壓縮系統及方法

Legal Events

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

Ref document number: 11858440

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11858440

Country of ref document: EP

Kind code of ref document: A1