Write an EventLog C# - SharePoint



 public class Logger
{
        string sSource;
        string sLog;

SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        public void EventLogWriter(string message)
        {
            sSource = "Test System Name";
            sLog = "Application";
            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, sLog);
            EventLog.WriteEntry(sSource, message, EventLogEntryType.Error, 1);
        }
});
}

----------------------------- Regards : Shashika Hettiarachchi -----------------------------

Comments

Popular posts from this blog

[SOLVED] The SharePoint Timer Service service terminated unexpectedly. Event ID : 7031

FIX : The password supplied with the username Domain\Username was not correct. Verify that it was entered correctly and try again.

FIX : stsadm is not recognized as an internal command