Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 285067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:30:46+00:00 2026-05-12T05:30:46+00:00

SUMMARY: How to configure a web service such that writing to the Event Log

  • 0

SUMMARY: How to configure a web service such that writing to the Event Log is always possible (regardless of caller)?
DETAILS:
I have a web service which writes an entry to the Application Log. I established the event source for this by means of a little console application and I think I understand that part of things. When I test this WS, I see I am successfully writing my entry to the Event log.

The virtual directory which hosts this WS does NOT allow anonymous access and is configured for Integrated Windows Auth only.

I have a web client application that calls this Webservice. When the web client site is configured for Integrated Windows Auth only, calls to the Webservice result in logging as desired.

Yet, if I change the web client site to allow anonymous access then the Webservice attempt to log results in an InvalidOperationException. I ignore it but it would be nice to know how to get logging in the webservice regardless of how it is called. Here is a bit of my code:

   public FileService()
    {
        try
        {
            if (!EventLog.SourceExists(g_EventSource))
                EventLog.CreateEventSource(g_EventSource, g_EventLog);

            System.Security.Principal.WindowsIdentity UserIdentityInfo;
            UserIdentityInfo = System.Security.Principal.WindowsIdentity.GetCurrent();
            string AuthType = UserIdentityInfo.AuthenticationType;

    if (AuthType == "Kerberos")
    { engineWSE.Credentials = System.Net.CredentialCache.DefaultCredentials; }
    else
    { engineWSE.Credentials = new System.Net.NetworkCredential("u", "p", "domain"); }

    EventLog.WriteEntry(g_EventSource,
                "Caller: " + UserIdentityInfo.Name +
                " AuthType: " + UserIdentityInfo.AuthenticationType,
                EventLogEntryType.Information, 1);
        }
        catch (InvalidOperationException e)
        {
            // do nothing to ignore: "Cannot open log for source 'myAppSourceName'. You may not have write access." 
        }
    }

The example in the constructor above is sort of contrived for here (I am mainly interested in being able to write out info related to errors in the web service).

I hope there is a way to configure the web service virtual directory (or the code within) so that logging is possible regardless of how it got called.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:30:47+00:00Added an answer on May 12, 2026 at 5:30 am

    You should also check your web.config.

    If IIS is set to anonymous and web.config is set to windows / impersonate. Then it will be the anonymous IIS user that is trying to write to the event log.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the summary: I need to build a simple java web app that,
I am writing a service using wcf. I have created a solution with two
I have a Mettler Toledo postal scale (PS60) that I need to configure and
Summary: I have passed the name of the id select tag into an Array.
Summary: I have an ASP.NET MVC website in IIS named 'Website' using an AppPool
I am using NHibernate in my web application. So far I have created this
Summary : I have a project using GNU Autotools. I have a pot file.
I have a worker role that works perfectly in development but doesn't work when
Given the following setup, I have three assemblies. Web (ASP.NET MVC 3.0 RC1) Models
I got a plain spring3 web project set up and have a controller method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.