Vibrant discussion about CSLA .NET and using the framework to build great business applications.

error logging ...

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 6 Replies | 2 Followers

Top 500 Contributor
36 Posts
SDM10012 posted on Mon, Sep 20 2010 4:43 PM

I need a solution for logging errors so that we can send a "friendly" message to users, but capture exception details to troubleshoot ....

I'm looking into ways to send errors to windows server error logs ... but am also interested in open source solutions or a product I can suggest to the "governance powers that be" for purchase.



All Replies

Top 10 Contributor
9,438 Posts

To my knowledge, the two most common logging frameworks are Enteprise Library and log4net.


Top 500 Contributor
36 Posts

Thanks, RL ... but what about  "normalizing this behavior" ?? ...  I'd prefer not having  to have complex logic in each BO to handle this .....

Where would I put code in one place that would

  • Let an exception-free call return the expected object or value to the caller
  • for Exception ... most likeley from a call to DataPortal

1) persist exception information to error log

2) send a friendly message to presentation layer  ( could be a property of the BO that is returned )

So no try/catch in the presentation layer .... just test for a return value in the BO returned from the function call.

When BO is returned from call (to DataPortal) the BO would know to either

  • process normally
  • display error message ( I'd need to establish an interface to insure each BO implements a way to set and test for the error)



Top 10 Contributor
2,250 Posts
JonnyBee replied on Tue, Sep 21 2010 11:19 AM


You should also add NLog to your shortlist of logging framework.

If you are going to consider a commercial product then take look at Gibraltar

In general terms -  in my apps I have created several exception types that I throw and have a general ExceptionWindows that will either display a "nice" message if based on UserFriendlyException otherwise will show a full stack trace.

And we have a custom exception logging service that logs the exception details for troubleshooting. NLog shows a really simple way of implementing this.

Jonny Bekkum, Norway CslaContrib Coordinator

Top 500 Contributor
36 Posts
SDM10012 replied on Tue, Sep 21 2010 11:40 AM

thinking out loud re: "normalizing behavior" ...

I could have an exception handler class that would be called in the catch method of DataPortal / potential source of error call ... so

If no exception ... returns normally

if exception ... passes exception to exception handler ...

  • exception handler logs exception for troubleshooting
  • sets "friendly" problem message in BO
  • returns expected return value with error condition set

makes sense ??

Top 10 Contributor
9,438 Posts

In you can override the BusinessBase.DataPortal_OnDataPortalException method (and the same in other classes) to be notified when an exception occurred during server-side processing.

If you have custom base classes for all the CSLA base class types (which is a good idea), then you can just override this method in your base classes to have pretty centralized handling of exceptions.

If you are using object factories, your factory objects should implement a public InvokeError(Exception) method to be notified of an exception. You can have a custom factory base class (subclass of Csla.Server.ObjectFactory) to do this for all your factory objects.


Top 10 Contributor
2,250 Posts

Well, what you are describing is possible in CSLA 4.0.x. See http://lhotka.net/cslabugs/edit_bug.aspx?id=679

The intention is foremost:

a) Replace NonSerializable exception with a generic exception
b) Replace a DAL specific Exception that is not available on the client (ex custom DB Drivers, MQ Exceptions etc) with a generic exception.
c) Centralized logging of all DataPortal exceptions in one class.

See the .NET/cs sample CusomErrorHandling.


Jonny Bekkum, Norway CslaContrib Coordinator

Page 1 of 1 (7 items) | RSS

Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems