LOG4NET:将动态值传递给附加程序

发布于 2024-12-10 04:11:45 字数 98 浏览 8 评论 0原文

实例化记录器后,我想根据代码的结果将一个值传递回 log4net。例如,如果一个方法返回“ABC Report”的值,我想将其传递回附加器并将其附加到 .

提前致谢!

After instantiating the logger, I would like to pass a value back to log4net based upon the results of my code. For instance, if a method returns a value of "ABC Report", I would like to pass that back to the appender and append it to the 'value' of the .

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香草可樂 2024-12-17 04:11:45

你的问题不是很清楚......

你的意思是你想做这样的事情:

var logger = LogManager.GetLogger(your logger name goes here);

logger.Info("Hello!);

int sum = 1 + 2;

logger.InfoFormat("the sum is {0}", sum);

当你调用 log4net 日志记录方法时,你正在将你想要 log4net 记录的“值”传递给 log4net 。

你想尝试做一些不同的事情吗?如果可以的话,尽量让你的问题更清楚。不要只是将您的澄清添加为评论。

Your question is not very clear...

Do you mean that you want to do something like this:

var logger = LogManager.GetLogger(your logger name goes here);

logger.Info("Hello!);

int sum = 1 + 2;

logger.InfoFormat("the sum is {0}", sum);

When you call the log4net logging methods, you are passing the "values" to log4net that you want log4net to log.

Are you trying to do something different? If you can, try to make your question more clear. Don't just add your clarification as a comment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文