简体   繁体   中英

How to configure log4net to write logs in Visual Studio 2015 Extensions

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>

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

but now there's nothing under

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!!)?

Thank you!

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>

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

like this

Cheers,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM