log4net - 磁盘上的数据库或文件
在 log4net 中使用文件附加器或数据库附加器是否被认为是最佳实践?
这是在网络场环境中,因此我发现管理多个站点的多个文件很困难 - 数据库是更好的方法吗?如果是,是否有任何问题?
我见过一些人抱怨连接池问题,例如
我的环境是 MVC + NHibernate
Is it considered best practice to use file appenders or database appenders in log4net?
This is in a web farm environment hence I'm finding it a struggle managing multiple files for multiple sites - is the database a better way to go, and if so, are there any issues?
I've seen some people complain of connection pooling issues for example
My environment is MVC + NHibernate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
默认情况下,日志记录不是异步的。记录到数据库比记录到文件要昂贵得多,但 Log4Net 的优点在于您可以从一个存储开始,然后根据需要进行切换。
BY default logging is not asynchronous. Logging to a database is much more expensive than logging to files, but the beauty of Log4Net is you can start with one store and switch if needed.
我认为最好的选择是在您的环境中有效的选择,这似乎是给定场的数据库。
log4net 的优点在于这只是一个配置开关,因此在数据库不起作用后切换回文件既不痛苦也不昂贵。如果您选择的话,您甚至可以记录多个内容 - 例如,在本地跟踪调试内容,审核事件转到数据库,“服务器已关闭”转到某个管理员的电子邮件地址。
I'd contend the best choice is what works in your environment, which seems to be database given the farm.
Beauty of log4net is this is all just a configuration switch so switching back to files after the database don't help isn't painful nor expensive. You can even log to multiple things if you so choose -- eg, trace debug stuff locally, auditing events go to the db and "the server is down" goes to some admin's email address.
或共享文件系统并写入文件(假设您的网络场都是同一家公司的一部分)
..您可以做的另一件事是混合策略,您将详细数据写入文件和摘要(可能是 INFO级别及以上)到网络套接字
or a shared file system and write a file (assuming your web farm is all part of the same company)
.. the other thing that you can do is a hybrid strategy, where you write detailed data to a file, and summary (perhaps INFO level and above) to a network socket