views:

206

answers:

3

Domain model should be dependency-less. Therefore - it must not contain any reference to logging mechanism. I understand that there are not any problems with logging infrastructure&application layer, but what if i want to log domain model? Is it not supposed to be logged, just unit tested & logged from outside (infrastructure/application)?

A: 

If you need to log the values you can use reflection to build a string description of your objects. Lots of platforms have ready-made libraries that can do things like this for your.

I really can't see many sensible use cases for logging from inside the domain model. Actually with good test coverage there's not many good technical use cases for logging at all. I suppose there may be some nice legal ones.

krosenvold
I see it the same, just wanted to know what others think. I'm the one who is going to convince his team to use DDD ideas for their project. It's going to be quite hard. For various reasons...
Arnis L.
+3  A: 

Your domain object can have events that notify the outside that things are happening inside.

Your infrastructure can attach to these events to log what's needed.

Think Before Coding
Now that's a good point. :)
Arnis L.
A: 

Try Log4PostSharp

Todd Smith