-1

I have a very simple WCF Workflow Service project with just 1 xamlx in it. XAMLX is also very simple with one receive receive activity and then calling an other xaml workflow.

Here is xamlx service:

enter image description here

My question is how can I configure Log4net in my xamlx service so that all the unhandled errors generated by subsequent Workflow can be logged to Event Log?

Nido
  • 241
  • 4
  • 22
  • Configure it programatically in the activity you call from your error handler. – stuartd Feb 26 '16 at 19:39
  • @stuartd I found that I can put `[assembly: log4net.Config.XmlConfigurator(Watch = true)]` in AssemblyInfo.cs for the configuration. But how can I Log errors within xamlx? – Nido Feb 26 '16 at 19:43
  • You will have to run c# code. I only used workflow as part of the old-style tfs build definitions but even in them you could load custom assemblies. Another optio (if available in your situation) would be to use the 'start process' activity, in which case you then have lots of options.. – stuartd Feb 26 '16 at 19:45

2 Answers2

0

You might want to take a look at Workflow Tracking and Tracing. Mainly on how to create your own TrackingParticipant where you've several TrackingRecords available to log. You can even create your own CustomTrackingRecord to be emitted by your custom activities.

Actually, you've already available an EtwTrackingParticipant that probably does the job you want, without using log4net. You can see here on how to configure it and access it's event data on Event Viewer.

Joao
  • 7,366
  • 4
  • 32
  • 48
-2

As I couldn't find any method which automatically logs all the unhandled errors. I have solved my problem by adding Try/Catch activity and adding some code activities to log the error.

To configure the Logger I added this [assembly: log4net.Config.XmlConfigurator(Watch = true)] to assembly.cs and then created 2 code activities.

One to get the logger:

  ILog logger = LogManager.GetLogger("LogName");
  return logger;

Second to Log the error:

  logger.Get(context).Error(ex.Get(context));

My Updated xamlx looks like below:

enter image description here

If anyone have any other better option, then please let me know. Thanks

Nido
  • 241
  • 4
  • 22