How to create Windows EventLog source from command line?

后端 未结 8 1474
温柔的废话
温柔的废话 2020-11-27 09:28

I\'m creating an ASP.NET application that will log some stuff to Windows EventLog. To do this an event source has to be created first. This requires administrative priviledg

相关标签:
8条回答
  • 2020-11-27 10:04

    Try PowerShell 2.0's EventLog cmdlets

    Throwing this in for PowerShell 2.0 and upwards:

    • Run New-EventLog once to register the event source:

      New-EventLog -LogName Application -Source MyApp
      
    • Then use Write-EventLog to write to the log:

      Write-EventLog 
          -LogName Application 
          -Source MyApp 
          -EntryType Error 
          -Message "Immunity to iocaine powder not detected, dying now" 
          -EventId 1
      
    0 讨论(0)
  • 2020-11-27 10:05

    Or just use the command line command:

    Eventcreate

    0 讨论(0)
提交回复
热议问题