I'm working out an implementation of ELMAH in a web application that logs exceptions to a SQL Server. That's inconsequential, however. My goal is to include the application name in the log so I can easily identify the offending application at a glance when checking error reports. I've searched far and wide spending hours trying to find a solution. I've included
As it is my practice to always fill out the assembly info for all my applications, I have elected to populate this field from
My.Application.Info.Title which I just figured out how to access programmatically. To set this field in ELMAH, I set the
ApplicationName value of my
SqlErrorLog object like so:
Dim se As New Elmah.SqlErrorLog(ConnectionStrings("Elmah").ConnectionString) se.ApplicationName = My.Application.Info.Title
The assembly info can be set by opening the project properties -> Application tab -> click Assembly Information... -> set "Title" value.
Now when you call the
Log function for this object, it will create a database entry including the Application Name.