Using your own logfiles in SharePoint 2007

After reading the MSDN on Trace Logs in MOSS/WSS, I wrote my own little class to Log messages and exceptions.

The trick is, that this Logging class will log to the same folder as MOSS 2007 will log to.

Example:

You can use this this code to easily write to your own Moss Logs:

try {
// some code
int i = int.Parse(“1”);
TamTam.SharePoint.Diagnostics.LogMessage(“MyLog”,“Category1”,“Integer i found”);
}
catch(Exception exc) {
TamTam.SharePoint.Diagnostics.LogException(“MyLog”,exc);
}

Download source code here Logging.cs (4.73 KB)

Download an assembly with this class here TamTam.SharePoint.Diagnostics.dll (16 KB)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: