Home All Groups Group Topic Archive Search About

Writing to Event Log (multiple lines in the description)



Author
10 May 2005 4:10 PM
Marco Shaw
I want to write events to the Event Log for testing purposes.  I've played
with utilities like logevent.exe and eventcreate.exe, but these don't seem
to be able to produce messages that span more than one line.

An example of a description that I need to duplicate:
Description:

The VB Application identified by the event source logged this Application
xyz: Thread ID: 3420 ,Logged: Source: [xyz]

Area: [xyz: App Server Request Failed]

Error Code: [-2147012867]

Message: [A connection with the server could not be established]



How can I do this?  Can it be done with some kind of scripting or will I
have to get deeper into VB?



I then need to figure out how I can script to search for these multi-line
events...



Marco

marco AT nbnet DOT nb DOT ca

Author
10 May 2005 6:25 PM
Martin Peters
Hello Marco,
"Marco Shaw" <ma***@Z.nbnet.nb.ca> schrieb im Newsbeitrag news:%23w6wSrXVFHA.3024@TK2MSFTNGP14.phx.gbl...
>I want to write events to the Event Log for testing purposes. 
(...)
>
> I then need to figure out how I can script to search for these multi-line
> events...

try it like this:

   'script to write to application eventlog
   dim oWSH
   dim sMsg

   set oWSH=CreateObject("WScript.Shell")
   sMsg="Line1" & vbCrLf & vbCrLf & "Line2"

   oWSH.logevent 4, sMsg
   wscript.quit

Martin
Author
10 May 2005 6:53 PM
Jim Vierra
Try this for scripts.

Dim sh
Set sh = CreateObject("WScript.Shell")
strmeszage = "This Is line 1" & VbCrLf & " This is Line 2"
iEventID = 2  '0,1,2
strComputer = "omega"
sh.LogEvent iEventID,strmeszage, strComputer

--
Jim Vierra

Show quote
"Marco Shaw" <ma***@Z.nbnet.nb.ca> wrote in message
news:%23w6wSrXVFHA.3024@TK2MSFTNGP14.phx.gbl...
>I want to write events to the Event Log for testing purposes.  I've played
> with utilities like logevent.exe and eventcreate.exe, but these don't seem
> to be able to produce messages that span more than one line.
>
> An example of a description that I need to duplicate:
> Description:
>
> The VB Application identified by the event source logged this Application
> xyz: Thread ID: 3420 ,Logged: Source: [xyz]
>
> Area: [xyz: App Server Request Failed]
>
> Error Code: [-2147012867]
>
> Message: [A connection with the server could not be established]
>
>
>
> How can I do this?  Can it be done with some kind of scripting or will I
> have to get deeper into VB?
>
>
>
> I then need to figure out how I can script to search for these multi-line
> events...
>
>
>
> Marco
>
> marco AT nbnet DOT nb DOT ca
>
>
Author
10 May 2005 6:59 PM
Jim Vierra
For command line utilities you can usually add "\n" in the string to cause
inserted line feeds (newline).

--
Jim Vierra

Show quote
"Marco Shaw" <ma***@Z.nbnet.nb.ca> wrote in message
news:%23w6wSrXVFHA.3024@TK2MSFTNGP14.phx.gbl...
>I want to write events to the Event Log for testing purposes.  I've played
> with utilities like logevent.exe and eventcreate.exe, but these don't seem
> to be able to produce messages that span more than one line.
>
> An example of a description that I need to duplicate:
> Description:
>
> The VB Application identified by the event source logged this Application
> xyz: Thread ID: 3420 ,Logged: Source: [xyz]
>
> Area: [xyz: App Server Request Failed]
>
> Error Code: [-2147012867]
>
> Message: [A connection with the server could not be established]
>
>
>
> How can I do this?  Can it be done with some kind of scripting or will I
> have to get deeper into VB?
>
>
>
> I then need to figure out how I can script to search for these multi-line
> events...
>
>
>
> Marco
>
> marco AT nbnet DOT nb DOT ca
>
>

AddThis Social Bookmark Button