1.  Field of the Invention
The present invention relates to a log recording apparatus, and in particular to a log recording apparatus capable of recording an event and a state in a monitoring target system while reducing the size of the record. 
2.  Description of the Related Art
Recently, it is increasingly common for a lot of apparatuses and systems to realize various functions by executing a program mounted on them.  In such apparatuses and systems, it is commonly performed to record operating conditions as a log for the purpose of facilitating identification of the cause of a trouble when it occurs, that is, troubleshooting. 
Such a log is recorded and stored in a storage device (such as a memory) included in an apparatus constituting the system.  However, there are a lot of cases where the recording capacity for holding the log is limited in order to reduce hardware cost.  Therefore, it is necessary to realize both of reduction in data size for satisfying the restriction of the recording capacity and facilitation of troubleshooting at the same time. 
There are proposed various techniques as log recording methods in order to keep the amount of information necessary and sufficient to facilitate troubleshooting while reducing the storage capacity for holding a log (for example, References 1, 2 and 3 listed herein). 
As techniques which satisfy the above requirements, mainly the solution methods as described below are proposed. 
1) Only an Event is Recorded in a Log
As a common log recording method, a method of recording only an event or only an event and the time of the event as log data is known.  FIG.  7 shows an example of a log in which only events and times are recorded. 
2) An Event is Recorded in a Log Together with a State
As a method in which the problems of 1) described above are improved, a method of log-recording an event together with a state is known.  FIG.  8 shows an example of the log in which both an event and a state are recorded together.  In the log format like that of the example in FIG.  8, a state before occurrence of an event and the event occurred are recorded as a pair together with time. 
In the example shown in FIG.  8, it is seen that an operation 2, which is an event before occurrence of an error 1 and an error 2, occurred in different states of State C and State D, respectively.  Therefore, in this example, the difference between the states in which the operation 2 occurred can be used as a clue for analyzing the cause of the problem.     Reference 1: JP-A 2006-107348 (KOKAI)    Reference 2: JP-A 2007-18100 (KOKAI)    Reference 3: JP-A 11-119860 (KOKAI)[Problems of the Conventional Techniques]1) Problem of the Case of Recording Only an Event in a Log
In general, there is known a method of recording only an event or only an event and the time when the event has occurred (see FIG.  7).  This method has the following problem. 
In general, even for the same event, the position (an execution line or a function in a program) which performs corresponding processing differs if the state of the system differs.  Therefore, it is difficult to identify the position of a cause from the log including only events.  The reason will be described below. 
FIG.  9 shows an example of a state transition diagram.  In the figure, each of reference symbols A, B and C denotes a state, and each of reference symbols e1, e2 and e3 denotes an event.  It is assumed that there is a system which operates in accordance with the state transition diagram and which records only an event as log data.  It is assumed that, in this system, a log “e1, e2” (which means that the event “e2” occurred after the event “e1” occurred) is recorded.  In this case, if the state when the event “e1” was received was “A”, then the state after the event “e2” was received was “C”.  If the state when the event “e1” was received was “B” or “C”, then the state after the event “e2” was received was “A”.  If the state when the event “e1” was received was “C”, then the state after the event “e2” was received was “A”.  That is, it is not possible to identify the states at the times when the events recorded in the log occurred, and therefore, it is not possible to identify the state in which a cause is thought to exist. 
In the example shown in FIG.  7, an error 1 and an error 2 occurred after the same event, “operation 2”.  As the cause that different errors occur after the same operation is performed, difference between internal states at the time when the operation was executed is conceivable.  However, since internal states are not recorded in the log recording format as shown in the example as described above, it is not possible to judge the cause of occurrence of the errors. 
If all events are recorded, it is possible to identify the current state by following the state transition even from the log including only events.  However, due to restriction of the recording capacity, it cannot be expected that the whole past log remains (some of them have been deleted by being overwritten).  Furthermore, in the case of the method of recording all events, since log data of events which are not important for troubleshooting is also recorded, the recording capacity is wastefully used.  An example of a state transition table of a certain system is shown in FIG.  2.  This state transition table is tabular-format data constituted by four kinds of states, “STOP”, “WAITING”, “REPRODUCTION” and “FAILURE”, and five kinds of events, “ON”, “OFF”, “PLAY”, “STOP” and “ERROR”.  The four kinds of states correspond to four lines, and the five kinds of events correspond to five columns.  This state transition table has four lines and five columns, and therefore, a total of twenty cells.  In each cell, there are stored a state to which the state transitions (any one of the four states described above; hereinafter referred to as a “transition-destination state”) and/or an action which occurs in the case where an event corresponding to the column in which the cell is included occurs in an state corresponding to the line in which the cell is included.  However, if state transition does not occur and/or no action occurs, data is not stored (such a case is denoted by the symbol “-” in the figure).  For example, if the event “ON” occurs when the state is “STOP”, this corresponds to the cell at the upper-left corner of the state transition table.  In the upper part of this cell, “WAITING” is written in the transition destination, and, in the lower part, the symbol “-” which indicates that an action does not occur is written.  That is, this indicates that, if the event “ON” occurs when the state is “STOP”, the state transitions from “STOP” to “WAITING”, and an action does not occur. 
If the event “ON” occurs when the state is “FAILURE”, this corresponds to the cell at the lower-left corner of the state transition table.  In the upper part of this cell, the symbol “-” which indicates that the state does not transition is written, and, in the lower part, the symbol “-” which indicates that an action does not occur is written.  That is, this indicates that, if the event “ON” occurs when the state is “FAILURE”, the state does not transition, and an action does not occur. 
If the event “PLAY” occurs when the state is “WAITING”, this corresponds to the cell on the central column and on the second line in the state transition table.  In the upper part of this cell, “REPRODUCTION” which indicates a transition-destination state is written, and, in the lower part, “START REPRODUCTION”, an action which is to occur, is described.  That is, this indicates that, if the event “PLAY” occurs when the state is “WAITING”, the state transitions from “WAITING” to “REPRODUCTION, and the action “PLAY” occurs.  In the other cells also, a transition-destination “state” and an “action” are written similarly. 
In this example, there may be a case where log data of events as shown below is not necessary. 
i) The Events of ON, PLAY, STOP and ERROR after a Failure Occurs
Because an event which occurs after a problem occurs has nothing to do with the cause of the problem. 
ii) The Event of OFF During Stop
Because it is experientially assumed not to cause a problem or because it can be presumed not to cause a problem from the viewpoint of the nature of hardware. 
The log recording method in which only an event is recorded has the problems as described above.  Troubleshooting is difficult unless an event corresponds to a state. 
2) Problem of the Case of Recording an Event in a Log Together with a State
As a method for improving the problems of the above-described log recording method in which only an event is recorded, a method of log-recording an event together with a state is known.  However, this method has the following problem. 
i) A Large Part of the Storage Capacity is Consumed
For example, in the case of the state model indicated by the state transition table shown in FIG.  2, 3 bits (five kinds of events) are required as the number of bits per data (corresponding to one line in a log) in the case of the conventional log recording method in which only an event is recorded, while 5 bits (3 bits (five kinds of events)+2 bits (four kinds of states)=5 bits) are required in the case of the log recording method in which an event is recorded together with a state.  That is, in comparison with the log recording method in which only an event is recorded, the log recording method in which an event is recorded together with a state has a problem that the data size is almost twice as much as that of the former method if the number of kinds of states and the number of kinds of events are almost the same between the two methods. 
[Comparison with the Present Invention]
The techniques of references described above and the present invention will be compared.     1) JP-A 2006-107348 (Kokai) “Log Recording Apparatus and Log Recording Method”
In this conventional technique, a target to be recorded in a log is restricted with the use of a unit finer than an event, in a system the recording capacity is limited.  An event is recorded together with information identifying the event.  When the log data is not necessary any more, the record is deleted (overwritten) for capacity optimization.  The technique disclosed in this reference is for recording an error event and identification information.  Since information identifying a cell in a state transition table is not recorded unlike the present invention, it is not possible to reproduce the state at the time when an event was received unlike the present invention.  Therefore, the technique is not sufficient for the purpose of troubleshooting.     2) JP-A 2007-18100 (Kokai) “Log Recording Apparatus and Log Recording Method”
This reference discloses a log recording apparatus and a log recording method which facilitate analysis of a failure.  In this conventional technique, information after shipment and information before shipment are differentiated from each other and recorded in an EEPROM.  This conventional technique is for recording only an error event, and such information identifying a cell in a state transition table as described in the present invention is not recorded.  Therefore, it is not possible to reproduce the state at the time when an event was received unlike the present invention, and the technique is not sufficient for the purpose of troubleshooting.     3) JP-A 11-119860 (Kokai) “Electronic Control Apparatus”
This conventional technique is for recording messages exchanged among objects, which have been obtained by fractionalizing a program for controlling a control target according to unit functions, as log data.  In this conventional technique, recording is not performed for predetermined processings for the purpose of improving the memory efficiency.  The log recording method according to this conventional technique is for recording only a message, and a state is not recorded.  Therefore, it is not possible to reproduce the state at the time when an event was received unlike the present invention, and the technique is not sufficient for the purpose of troubleshooting.  Furthermore, in the case of inhibiting recording of certain processing as done in this conventional technique, the recording is always inhibited irrespective of the state of the system.  The technique is different from the present invention in that it cannot realize fine optimization, such as “inhibiting recording in a certain state”, unlike the present invention. 
The object of the present invention is to solve the problems of the conventional techniques as described above.  In particular, the object is to make it possible to leave records with which analysis of a cause can be efficiently performed when a trouble occurs in an observation target system and realize reduction in the size of the records at the time of recording.