1

We have developed a timer job for SharePoint 2013 in Visual Studio 2012. It is scheduled to be running between 7 AM to 7:15 AM. We have deployed the timer job using PowerShell. In code we have added PortalLog.LogString to log messages in SharePoint error logs at the beginning of the timers execute method.

Under Site Collection we can see that it is deployed and activated. The scope of the timer job is set to Site in VS. We can see the timer job which is deployed in the review job definitions in central admin. But, cannot see it in scheduled jobs. When we go to edit the timer job via review job definitions, and hit 'Run Now', we cannot see any messages in the error logs that we have programmed using PortalLog.LogString.

What could be the issue?

Cœur
  • 37,241
  • 25
  • 195
  • 267
variable
  • 8,262
  • 9
  • 95
  • 215

2 Answers2

0

Sorry - too long for a comment. Will edit to represent an answer later.

You have to clarify quite a few things here: "Under Site Collection we can see that it is deployed and activated" - you mean you have a site collection feature to deploy a timer job? Timer jobs are installed at farm level, hence it should be a webapp/farm feature.

PortalLog.LogString is for internal use only: PortalLog.LogString method

Did you try debugging the timer job? As it is correctly deployed to "job definitions" and you can click Run Now everything looks good so far. You only have to attach to the SPTimerV4 (SharePoint Timer Job) for the breakpoints to be hit in your solution.

You should use different logging such as explained here: https://sharepoint.stackexchange.com/questions/55381/timerjobs-and-uls and before waiting for any logs to magically appear: Debug!

Community
  • 1
  • 1
Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • I wish there was VS on the live machine.. thats is why I cannot debug it... I can debug it on dev environment and it hits the point. The logs get appeared too.. This isnt working on LIVE.. Any idea? – variable Jan 31 '14 at 05:32
  • Again: Use different logging. On your dev machine everything might be installed under the same account - the timer job usually runs in a different account than your web applications hence he doesn't always have access to certain stuff e.g. logs. Timer job is quasi SharePoint external - think of it as such and use the event log for logging or really implement ULS Logging. If all fails - use `Debug` logging and fire up http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx DebugView to see your logs. – Dennis G Jan 31 '14 at 05:58
  • I just tried using the event viewer example, on DEV env we can see the error logged in event viewer.. But, on LIVE env onclick of 'Run Now' there is no item in event viewer.. Any idea? The scope of our timer job is = Site in VS.. – variable Jan 31 '14 at 07:12
  • tried to set in VS the scope to FARM, still cannot see log messages. – variable Jan 31 '14 at 12:38
  • Tried scope as Web Application, still not getting log messages... Any idea? – variable Jan 31 '14 at 12:38
  • The feature scope has nothing to do with the timer job scope. In the DEV env you can see erorrors logged in the event viewer. Great news! Do you get any errors in the event viewer at all about permissions and the like? With which user account is your **sharepoint timer service** running? – Dennis G Jan 31 '14 at 16:46
  • By error I mean the custom error messages I am coding... Where do I check permission related errors? Timer service is running under site collection admin account.. – variable Feb 01 '14 at 04:43
0

It seems to me that there are two issues:

  1. You should use other way for logging LoggingService should be preferred way. Use WriteEvent to write to EventLog or WriteTrace to write to ULS log.
  2. Running job. Be sure that Owstimer.exe service on all web servers are restarted (can be done by this powershell script). I expect that you have correctly scheduled your job either in your powershell script or in your feature receiver.
Jan Vanek
  • 889
  • 1
  • 6
  • 8