编程方式迫使一个新的日志文件log4net的 [英] Programatically force a new log file with Log4Net

查看:108
本文介绍了编程方式迫使一个新的日志文件log4net的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注:我读了这个问题,答案,它不适合我想要的工作:<一href="http://stackoverflow.com/questions/308436/log4net-programmatically-specify-multiple-loggers-with-multiple-file-appenders">Log4Net:编程指定多个记录器(带有多种文件追加程序)

我有一个WCF服务,这是一个问题与答案式的服务。它得到的输入和发送输出。它根本不坚持多

I have a WCF service that is a "Question and Answer" style service. It gets inputs and sends outputs. It does not persist much at all.

我需要登录每个问题,在一个单独的文件问答环节。

I need to log each Question and Answer session in a separate file.

我有一个单独的追加程序(目前RollingAppender)。

I have a single Appender (currently the RollingAppender).

是否有某种方式开始每次调用我的WCF服务的一个新的日志文件?

注:我使用的是XML的布局,这个想法是,日志的输出可以解析,并以图形方式显示(以后的功能)。有点像一个查询计划。这是我需要他们在一个单独的文件中的另一个原因。

NOTE: I am using an XML Layout, the idea is that the output of the log can be parsed and displayed graphically (a later feature). Kind of like a "Query Plan". This is another reason that I need them in a separate file.

注:如果是需要一个理由,log4net的XmlLayoutBase不会下降XML页脚,直到应用程序关闭。这是不是一个真正的计划事件的WCF服务托管在IIS中。

NOTE: In case another reason is needed, the Log4Net XmlLayoutBase will not drop xml footers until the app closes. Which is not really a planned event for an WCF Service hosted in IIS.

推荐答案

而不是记录到文件中,也许你可以试着登陆到数据库表和记录的数据记录会话ID。这样,您就可以做对选择基于会话ID的表,只看到他们的数据。

Instead of logging to a file, maybe you could try logging to a database table and log the session id with the logged data. This way you can do selects against the table based on the session id and see only their data.

这篇关于编程方式迫使一个新的日志文件log4net的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆