将应用程序日志转发到Windows事件日志

将应用程序日志转发到Windows事件日志

问题描述:

我想为我的服务器上运行的应用程序创建一个新的EventLog,并且日志应该从应用程序的默认日志文件中获取。将应用程序日志转发到Windows事件日志

任何想法如何实现这??。

你的意思是事件源? PowerShell的将是 则New-EventLog命令发现这里提供的更详细的编辑后

MSDM New-eventLog

你想要什么的基本原理是查询日志文件并将找到的行写入事件日志。这就好比做如下:

#Get the content of the error log, gets the top 10 lines ONLY!! 
$GetLog = Get-Content -Path D:\Errorlog.txt -totalcount 10 

#Now take the data found and write it to the event log under the source and log below 
Write-EventLog -LogName "Application" -Source "My Application" -Eventid 1001 
-EntryType Error -Message "$Getlog" -Category 1 
+0

我需要显示在事件日志窗口中的应用 myapplication.log --->应用程序事件日志窗口 –

+0

,我收到你现在的日志。我认为这是可能的....承担我 –

+0

谢谢理查德,但我怎么能够实时做到这一点 –