How to write to event Log with in my web application

I have tried this code to write to the event log with no success.  Didn't think it would be that easy.  Could someone send me in the right direction.

imports system.diagnostics


 Dim myLog As New EventLog("")
                    myLog.Source = "ResidentPortal"
                    myLog.WriteEntry("Invalid Password Attempt", EventLogEntryType.FailureAudit)
mgmhicksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
You surely don't have permissions (or IIS doesn't have permission) to do it. Check https://support.microsoft.com/en-us/kb/2028427
0
Jacques Bourgeois (James Burger)PresidentCommented:
Think of the mess if web pages could write to the EventLog.

The EventLog is there to diagnose what happens on the computer. So it is available to the operating system and to the applications that run on that computer. A Web application runs on one computer, but displays on another one.

Problems do not occur on the computer on which the page is displayed, so the log is not available there. Think of all the scrap that would be put there and the mess it would become if every web page could write there. It's already enough of a mess with cookies.

Because the web application runs on the server, you might think that the right would be given on the server computer. But think of the mess there to. If 10,000 users request a page that writes to the event log, you would end up with 10,000 entries similar entries in the log. That would render the log useless for the applications that properly use the log.

If you want to log some information, do it in a database on the server side. On the user side, post a message on the screen.
0
Athar SyedCommented:
Look into NLog. Very easy to use, highly customizable and quite reliable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgmhicksAuthor Commented:
Didn't end up doing it, but all points were either valid or helpful.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.