[英]How to flush the Windows Event Log to disk?
I have a Windows 7 embedded device which is frequently power cycled like this: a local application writes an entry to the Application event log and a few seconds later it commands the custom power supply to cycle power.我有一个 Windows 7 嵌入式设备,它经常像这样循环电源:本地应用程序将一个条目写入应用程序事件日志,几秒钟后它命令自定义电源循环电源。 A clean Windows shutdown cannot be done.
无法完全关闭 Windows。 After the device boots back up, I check the Windows event log and notice the last entry missing.
设备重新启动后,我检查了 Windows 事件日志并注意到缺少最后一个条目。
Is there some way to flush the Windows event log to disk so that I don't miss that last entry?有没有办法将 Windows 事件日志刷新到磁盘,这样我就不会错过最后一个条目? The application is written in C++.
该应用程序是用 C++ 编写的。
Thanks, Adnan谢谢,阿德南
You have a hardware problem so the best solution is to resolve it in hardware.您有硬件问题,因此最好的解决方案是在硬件中解决它。 But moving on.
但是继续前进。
Use BIOS to ensure computer always starts after a power cycle使用 BIOS 确保计算机在电源循环后始终启动
You have a hardware tool to perform the reboot.您有一个硬件工具来执行重新启动。 Could you reconfigure that so that rather than doing a hard power cycle while the computer is running, you:
您能否重新配置它,以便在计算机运行时不要执行硬重启,您:
There is usually a bios setting which allows you to specify the action after a power cycle, eg通常有一个 bios 设置,允许您在电源循环后指定操作,例如
If you can do this, then you can still do an orderly shutdown and wait for that to complete before powering on again.如果您能做到这一点,那么您仍然可以按顺序关机并等待关机完成后再重新开机。
Software Solution: Turn off disk write caching软件解决方案:关闭磁盘写缓存
It's not exactly clear what is causing your issue, but the following seem relevant.目前尚不清楚是什么导致了您的问题,但以下内容似乎相关。
Most likely, this is a result of disk write caching either by the disc controller hardware, or by the operating system.这很可能是磁盘控制器硬件或操作系统对磁盘写入缓存的结果。
You may be able to turn this off through the Disk Management tool:您可以通过磁盘管理工具关闭此功能:
Software Solution: Flush the disk programmatically软件解决方案:以编程方式刷新磁盘
Alternatively, you may be able to flush the disk cache programmatically.或者,您可以以编程方式刷新磁盘缓存。 This tool may help:
该工具可能有助于:
Or indeed with WMI and PowerShell:或者确实使用 WMI 和 PowerShell:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.