is it true that we can t write information to event log or text file while developing for sharepoint

Hi,

I code for sharepoint, but I need to log errors that might occur for users. When a user is using sharepoint, will the process be able to write information to event log or files for a domain user who has no administrative permissions on the server or will the process run under the user's priveliges and therefore any attempt to write to event log or text file on the server will mainly fail

What s a good practice, guys, for logging and reporting either information or errors in production environnement wen we program for sharepoint.

Thanks a lot.



Answer this question

is it true that we can t write information to event log or text file while developing for sharepoint

  • eldiener

    What exactly do you want to do

    Every time a user does something, the W3WP-Process handles the requests, and he has the rights to write to the event log. Beside workflows, you can also use event handlers for a lot of events. And there you can also write to the event log.

    But I think, you want to do something, that should not be logged in the event log. The event log is only for system internal data and debugging purposes. So, if you want to log user actions, use a custom list and event handlers, to log customized data, or setup the versioning for a list.


  • rctaubert

    I got this link in another forum. I think it explains that in professionnal way :)

    http://www.15seconds.com/issue/040511.htm

    Thanks a lot.


  • Piyush77

    that s in the case of a worflow, but how about when a regular user is using sharepoint, i think sharepoint does an impersonnation, runing under the user's credentials, threfore any attempt to write to server resources runs under user s permission, which might fail in this case. How do we resolve this puzzle

    Gracias


  • Deathstryker

    Im coding a workflow in VS2005 atm and I'm using the servers event log for logging debug messages. This works fine, as the W3WP-process has the needed rights to write there.

    I'm using the following code:

    [NonSerialized] private EventLog log;
    private void DebugMessage(string msg)
    {
    if (!debug) return;
    //EventLog erzeugen
    if (log == null)
    {
    log = CreateEventLog();
    }
    log.WriteEntry(msg);
    }
    private EventLog CreateEventLog()
    {
    if (!EventLog.SourceExists("Office SharePoint Server"))
    EventLog.CreateEventSource("Office SharePoint Server","Application");
    log =
    new EventLog("Application");
    log.Source =
    "Office SharePoint Server";
    return log;
    }


  • is it true that we can t write information to event log or text file while developing for sharepoint