To which 开发者_高级运维layer does the logger belongs in DDD?
What would we want to log in DDD?
Important events that occur, of course.
The Logger itself is a service of the infrastructure. Bridging the domain and the logger can occur in an event handler.
Logging fits well inside of event handlers and when placed there it creates a very nice separation of concerns.
I'm not sure what your requirements for a logger are, but if you are using it for creating an audit trail to track changes to an aggregate then it should go into the repository layer.
精彩评论