加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

event-log – 由于系统关闭,我如何记录Windows服务正在终止?

发布时间:2020-12-14 04:27:25 所属栏目:Windows 来源:网络整理
导读:我有一个服务的诊断版本,尽可能在OnStart()和OnStop()方法中记录. 我无法捕获的一个事件是计算机物理重启.我的日志记录功能通常将其输出记录到数据库中的表中,但是当它不可用时,它会发布到EventLog. 在重新启动时,我的服务既不会记录到表也不会记录到EventLo
我有一个服务的诊断版本,尽可能在OnStart()和OnStop()方法中记录.

我无法捕获的一个事件是计算机物理重启.我的日志记录功能通常将其输出记录到数据库中的表中,但是当它不可用时,它会发布到EventLog.

在重新启动时,我的服务既不会记录到表也不会记录到EventLog.

因为SQL Server正在关闭,所以我无法发布到表中,但似乎由于计时问题,EventLog也可能在服务默认为关闭之前关闭写在那里.

在关闭的情况下,MSSQLSERVER在EventLog中报告信息消息:

SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.

有没有办法为我的服务做类似的事情?

解决方法

您可以指定 Windows服务的依赖关系,以使其需要其他服务.如果您指定对EventLog服务的依赖关系,则Windows将等待您的服务关闭,然后再关闭事件日志.

http://kb2.adobe.com/cps/400/kb400960.html描述了如何通过修改一些注册表项来完成它.

Navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices and locate the service that you need to set a dependency for. Open the ‘DependOnService’ key on the right side. If the selected service does not have a ‘DependOnService’ key,then create one by right-clicking and selecting New > Multi-String Value. In the value field,enter the names of all services that the current service will depend on. Each service name must be entered properly and on a separate line.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读