Программирование в IIS


Пример 3.9


///

/// logs messages to event log

/// in: string that contains message of error

/// or information that ought to be logged

///

/// out: returns true if successful write,

/// rethrows the error if failure occurs

///

///

[WebMethod]

public bool LogMessage(string Message, bool Error)

{

System.Diagnostics.EventLogEntryType MessageType;

try

{

//determine the type of message

if (Error )

{

MessageType =

System.Diagnostics.EventLogEntryType.Error;

}

else

{

MessageType =

System.Diagnostics.EventLogEntryType.Information;

}

//make the write

this.Log.WriteEntry(Message, MessageType);

}

catch (System.Exception eLogWrite)

{

//nothing else left to do except throw the raw error

throw eLogWrite;

}

//we have success if we get to this line

return true;

}




- Начало -  - Назад -  - Вперед -



Книжный магазин