问题
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!
回答1:
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,
来源:https://stackoverflow.com/questions/38282709/how-to-configure-log4net-to-write-logs-in-visual-studio-2015-extensions