开发者

NLog and logging to database in a repository pattern project

开发者 https://www.devze.com 2023-02-09 00:11 出处:网络
In NLog, to target a database for logging, you just enter the database connection, etc an开发者_如何学Pythond it connects straight to the db and does its stuff. My project uses the repository pattern,

In NLog, to target a database for logging, you just enter the database connection, etc an开发者_如何学Pythond it connects straight to the db and does its stuff. My project uses the repository pattern, which all access to the db goes through the repository. How do I setup NLog to log to my database using the repository? Should I create an ILoggingRepository? How do I use this in the NLog configuration?

Or should NLog be doing its connection straight to the db because its a logging framework?


It's good that you are abstracting with a data access layer. However the repository pattern is meant/intended for your domain objects. Think of logging as service and not as a domain object. Logging can be persisted to various locations. Don't create an ILoggingRepository. Just configure NLog to persist to the db directly.

0

精彩评论

暂无评论...
验证码 换一张
取 消