The optimal dynamic logic is developed for safety monitoring systems, which have two types of contradictory failures: a fail-dangerous and a fail-safe failure. The term “dynamic” means that the logic is reconstructed every time when new monitored data are obtained. The optimal dynamic logic is determined by a switching function of a history of monitored data, and it minimizes an expected damage caused by the two failures at the next monitoring time. Illustrative examples show various characteristics of the dynamic logic as compared with ordinary static logic. A calculation method of the switching function is demonstrated in detail.