Link to home
Start Free TrialLog in
Avatar of Service Desk
Service DeskFlag for United States of America

asked on

SharePoint 2010: Errors not showing up in diagnostic log

I am having an issue with the error logging in our development SharePoint 2010 box. This is a new install. When working on an application page, I had an error and went to the logs. Pretty much every other thing in the world is in the logs except for my error(s). I looked for the correlation ID and time and nada.

I've followed tutorials on how to configure the diagnostic logging. We have a stanging machine that I was working on until the dev machine was up and the logging worked fine there. I used that as an example and set the SharePoint Foundation and SharePoint Server categories to Error and Medium (I've even set them both to Verbose) with no result.

Anyone else have an issue with this?
Avatar of abhitrig
abhitrig
Flag of United States of America image

Few pointers worth considering:
-Check the log path in the CA and make user its pointing to the correct location (where you are looking for the files)
-If you are using the ULS viewer, try to open the viewer first and the repeat the actions that generate the error. By default ULS viewer only shows the error since it was opened (unless you open a file explicitly)
-Try searching for the correlation token by opening the file in notepad and the search for the partial guid....so remove the first and last section of the guid. I once had this weird case where it was not searching for the complete guid but the partial guid search was fine

Avatar of Service Desk

ASKER

Thanks for your response. The diagnostic logging path is set to '%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\14\LOGS\'. I can tell that this is the right path because when I set it to verbose, I can see a LOT more data arriving into the log. Good idea on the partial GUID search but I tried all permutations of the GUID tokens and nothing.

This is so weird. I would just do a comparison of of Staging box and my Dev box but I don't even know what to compare.

I could also do explicit logging in my code, but having to do that for every conceivable point of failure will get tiring.
Try restarting the "SharePoint 2010 Tracing" service.  I have seen that cause this type of issue before.
I agree that this does not make sense.

Please try the below:
- Turn on the ULSviewer (i hope you are not not using notepad, etc) and the repeat the steps that are causing the error. do you see any activity in the ULS viewer, like requests opened to your web, etc? you can also note the time and look in that range
-Try turning on the Developer dashboard. It should give you more details on the error page.

And just to be sure, this page where you are getting this error is an out-of-the-box SP page? or a webpart page with a webpart, etc?
Liebrand: I restarted the tracing service with no result.

Abhitriq: As much as I love my Notepad++, I'm not using that. ;-) I am using the ULS viewer. But I do not see the system logging such things as opening my web, accessing the particular page, etc. It also seems that the developer dashboard doesn't come up if there is a fatal error.
Also, this is not an out-of-the box page. This is an application page that I have created.
What error are you getting?  Perhaps you are getting an error at a layer before SharePoint and therefore it is not going to log it.
I'm getting a correlation ID and timestamp. Does that sound like it's the SharePoint layer? But of course I can't see what exactly the error is.
I activated the Developer Dashboard. I can see the error (of a well-made page) in the dashboard, but not in the logs. By well-made, I mean a page that doesn't have an errors that would cause the page to not even load. Those is the case, apparently, with my earlier attempts. I just created a page that simply has a button and when clicked throws a new error (see attachment). But that error is still not logged, nor does the log even say that my page is being called.   User generated image
So you are trying to log your "custom error" to the ULS logs...right? If that is the case i dont think SP will automatically write it for you. You will have to write your custom errors on your own.
http://blogs.msdn.com/b/sowmyancs/archive/2010/04/17/how-to-write-custom-logs-into-uls-logs.aspx

SP traps any "SharePoint related errors", errors from the native pages and throw the correlation id and then logs the error.
Back on my staging server I used these same application page projects, and if there was an error it would write them to the logs (without my needing to write methods to do so).
That depends on the kind of the error. If its related to native SP issues, like security validation, masterpage association, etc...they will get logged to the ULS logs.
The application pages are derived from ApplicationsLayoutsBase, so any errors that get caught by the SP base platform will be handled by SP. Any custom errors, say some business logic, etc will have to be handled by your code explicitly.
Could you make your source available for this test page?
I have attached a piece of code. It's using LINQ-to-SQL classes to connect to a database. After putting in the try-catch and using the SPDiagnosticsService class, it doesn't crash (with correlationID) anymore but it still doesn't go into the log.  
try
            {
                NBICPortalDataContext ndc = new NBICPortalDataContext("data source=NB-UAT-DB-01;initial catalog=NBIC_Portal;persist security info=False;user id=sql_portal;password=PortalService!;packet size=4096;");
                var collAgencies = ndc.sp_Agencies_Adresses_GetAllActiveMaster();
                Label1.Text = collAgencies.Count().ToString();
            } catch (Exception ex) 
            {
                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("AppPage", TraceSeverity.Medium, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);
            }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of abhitrig
abhitrig
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
After much back-and-forth, I checked the Performance Log Users group and it was EMPTY! I put in my AppPool service account and farm account into that group and also I had to assign the "Log on as a batch job" user right to the Performance Log Users group.

Thank you!