如何配置log4net以在Visual Studio 2015扩展中写入日志 [英] How to configure log4net to write logs in Visual Studio 2015 Extensions

查看:285
本文介绍了如何配置log4net以在Visual Studio 2015扩展中写入日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的Visual Studio扩展从2012年-2013年移植到2015年. 我有一个带有以下部分的log4net配置文件:

I'm trying to port my extension of Visual Studio from 2012 - 2013 to 2015. I have a log4net configuration file with the following section:

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
  <file value=".\mylog.log" /> 
  <appendToFile value="true" />
  <maximumFileSize value="1000KB" />
  <maxSizeRollBackups value="2" />

  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="[%d{ddMMM HH:mm:ss,fff}] %5level %logger (%line) - %message%newline" />
  </layout>
</appender>

在VS的早期版本中,我可以在

In the previous versions of VS, I was able to find my logs under

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\log
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\log

但现在

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\log

这里的最佳做法是什么(不在配置文件中刻出固定路径!)?

What's the best practice here (without carving a fixed path in the config file!!)?

谢谢!

推荐答案

您可以在log4net配置XML文件中使用"DebugAppender".

You can use "DebugAppender" on your log4net configuration XML file.

<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
    <immediateFlush value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="*%-10level %-30date %message [%logger] [%thread] %newline" />
    </layout>
</appender>

这会将您的日志输出到VS中的Ouput控制台中.

This will output your log into the Ouput Console in VS.

像这样

干杯

这篇关于如何配置log4net以在Visual Studio 2015扩展中写入日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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