Home > Microsoft SharePoint 2010 > How to write programmatically into ULS log?

How to write programmatically into ULS log?

Hi Friends,

SharePoint uses ULS log to add the activities like error logging, notifications and other. ULS log is available at 14hive/Logs folder.

So, why can’t we use the same to log our exceptions and information.

We can use following code to log the entry in ULS log.Remember to add the reference to the Microsoft.Office.Server dll in your project.

Microsoft.Office.Server.Diagnostic.PortalLog.LogString("Error – {0} – {1} – {2}",
"Message:",exception.Message+"\n Trace : ",exception.StackTrace);

Happy coding….

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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: