Every once in a while, I need to write to the Application EventLog from a BizTalk Orchestration, although I usually have my own SQL trace that I write to.
On almost all the overrides for WriteEntry, the first parameter is “Source”. I suggest you try some existing source, such as “XLANG/s” or “BizTalk Server”. You can create your own source, but then if you are not running in Admin mode, and you are the first person to write with that source, you will die with an error. (See separate section on that further below.)
Sample Code in an Orchestration Expression Shape
System.Diagnostics.EventLog.WriteEntry( "XLANG/s", "eSecuritel SSO Issue: " + exSOS.ToString(), System.Diagnostics.EventLogEntryType.Error);
I used the above in a “Catch Exception” within a scope.
You can see the other overrides here , but the one above with three parms seems to be the most common.
By the way, I got too fast typing, and actually put in System.Diagnostics.TraceEventType.Warning. The Trace has the shares some levels that the EventLogEntryType has (Severe, Error, Warning, Info), but has more options. Needless to say, I had the red-squiggly line under some code, and of course it wouldn’t build because of a signature mismatch.
Creating your Own Event Source
This must be done in advance by an administrator. There is a windows command that will do it for you, either run it from the command prompt, or put it in a .cmd/.bat file:
eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO MYEVENTSOURCE /D "My first log"
or if you prefer PowerShell, do something like this:
Write-EventLog -LogName Application -Source "MyNewSource" -Message "My first log" -EventId 0 -EntryType information
One trick to remember is that if you do this on your test system, you will have to remember to do it when you deploy up to the next higher environment (e.g. QA, UAT, or Production).