Content Studio Web Content Management System
Assembly: CSSubscriptionEventHandler (in CSSubscriptionEventHandler.dll) Version: 1.0.0.0 (1.0.0.0)
The following code shows how to add a custom header to each message written to the
log.
The following code does the same thing but shows how to take complete
control over how the message is written to the Logger object.
[This is preliminary documentation and is subject to change.]
Writes a message to the logger provided that a logger exists.
Namespace: ContentStudio.Document.Subscription.EventHandler
Assembly: CSSubscriptionEventHandler (in CSSubscriptionEventHandler.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
Parameters
- priority
- Type: ContentStudio.ServiceManager.LoggingSyslogPriority
The priority. - message
- Type: SystemString
The message.
Remarks
A developer can call this method to write her own messages to the log. If no log has been specified, this method does nothing.
Note |
---|
If you choose to override this method you can have precise control over all log writing operations. However, if you do not call the base class implementation and writes directly to the ISysLogWriter interface returned by Logger property, you must check that Logger exists (not null) and that it is writeable (check the CanWrite returns true). |
Examples
C#
public override void WriteToLog(SyslogPriority priority, string message) { //no use to write empty messages if(String.IsNullOrEmpty(message)) return; //Add a custom message before the regular message message = String.Concat("Myhandler message: ", message); //Write to the logger now base.WriteToLog(priority, message); }
C#
public override void WriteToLog(SyslogPriority priority, string message) { //the logger is null or not writeable, nothing to do if (Logger == null || !Logger.CanWrite) return; //No empty messages if (String.IsNullOrEmpty(message)) return; //Add a custom message before the regular message message = String.Concat("Myhandler message: ", message); //Write to the logger now Logger.WriteMessage(priority, message); }
See Also