Jump to content

Write to Windows event log: Difference between revisions

Using Write-EventLog
(Using Write-EventLog)
Line 423:
<br>
''Note2:'' See details on registering a new Event Source with Windows at [http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.registerdisplayname.aspx MSDN]
 
===Source and event log existing===
<lang powershell>
$MessageFreeLula = 'Global unions and union leaders from more than 50 countries came together ' +
'in Geneva today to stand in solidarity with former Brazilian President Lula, calling for ' +
'his immediate release from jail and that he be allowed to run in the upcoming elections.'
Write-EventLog -LogName 'System' -Source 'Eventlog' -Message $MessageFreeLula -EventId 13 -EntryType 'Information'
'SUCCESS: The Lula Livre message (#FreeLula) has been recorded in the system log event.'
</lang>
{{out|output}}
<pre>
SUCCESS: The Lula Livre message (#FreeLula) has been recorded in the system log event.
</pre>
===New event log===
<lang powershell>
$MessageFreeLula = 'Global unions and union leaders from more than 50 countries came together ' +
'in Geneva today to stand in solidarity with former Brazilian President Lula, calling for ' +
'his immediate release from jail and that he be allowed to run in the upcoming elections.'
New-EventLog -LogName 'Free Lula!' -Source '#FreeLula'
Limit-EventLog -OverflowAction 'OverWriteAsNeeded' -MaximumSize (64KB*13) -LogName 'Free Lula!'
Write-EventLog -LogName 'Free Lula!' -Source '#FreeLula' -Message $MessageFreeLula -EventId 13 -EntryType 'Information'
'SUCCESS: The Lula Livre message (#FreeLula) has been recorded in the "Free Lula!" log event.'
</lang>
{{out|output}}
<pre>
SUCCESS: The Lula Livre message (#FreeLula) has been recorded in the "Free Lula!" log event.
</pre>
 
 
=={{header|Python}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.