【发布时间】:2020-07-29 13:21:24
【问题描述】:
我试图做的是增加与我们的应用程序一起部署的 Windows 事件日志的限制,但我遇到了一种障碍。
好的,让我解释一下。我使用 Microsoft Diagnostics nuget 包创建了事件清单清单:Microsoft.Diagnostics.Tracing.EventSource 和 Microsoft.Diagnostics.Tracing.TraceEvent。 然后在安装期间将清单和相关资源库部署到目标机器。这是使用 wix 完成的,使用的代码看起来有点像这样:
<Directory Id="System64Folder" Name="SystemFolder" >
<Component Id="EventSource" Guid="4ce67f42-a687-99ee-b45c-1d88aa20b805">
<File Id="etwManifest.dll"
Source="$(var.BaseDir)\Company.ServiceLayer.Interfaces.Company-Product-Module.etwManifest.dll" >
</File>
</Component>
</Directory>
<Component Id="EventManifest" Guid="7eb9a485-c447-6932-87f0-6b08b41d99ee">
<File Id="etwManifest.man"
Source="$(var.BaseDir)\Company.ServiceLayer.Interfaces.Company-Product-Module.etwManifest.man">
<util:EventManifest MessageFile="[System64Folder]Company.ServiceLayer.Interfaces.Company-Product-Module.etwManifest.dll" ResourceFile="[System64Folder]Company.ServiceLayer.Interfaces.Company-Product-Module.etwManifest.dll"></util:EventManifest>
</File>
</Component>
到目前为止一切正常:我什至可以在应用程序和服务日志下看到事件日志,并且事件被写入日志。
问题是事件日志的默认大小为 1 兆字节,我们的客户担心这不足以满足他们的需求,因此我们想要更改它。我试过用 wix 看看这是否可行,但我的搜索表明不是。
然而,我确实发现这篇文章建议运行一个 powershell 脚本可能会有所帮助。链接在这里:Increase/Decrease the size of Event Log on Install
我确实设法让脚本在安装过程中运行,但随后出现此错误:Limit-EventLog : The Log name "Company-Product-Module/Operational" does not exist in the computer "localhost"
接下来我会进行一些挖掘并尝试寻找日志。我尝试使用日志文件“Company-Product-Module%4Operational”的名称或从名称中删除“Operational”,但没有运气。
也在运行get-eventlog -list 并且我的日志没有列出,尽管我可以在事件查看器中清楚地看到它。与Get-WmiObject Win32_NTEventlogfile 相同的故事
问题是我错过了什么?我是否缺少注册表项?这就是powershell看不到日志的原因吗?
【问题讨论】:
标签: windows powershell wix event-log