Có cách nào để định cấu hình log4net để in nhật ký cả về bàn điều khiển và tệp trong khi gỡ lỗi không?Cách cấu hình log4net để in sang bàn điều khiển ở chế độ gỡ lỗi
Tôi đang cố gắng tìm cách gỡ lỗi phần mềm của mình một cách hiệu quả bằng cách quan sát nhật ký ngay lập tức khi chúng xảy ra.
Việc ghi vào tệp là vấn đề đối với tôi để gỡ lỗi vì tôi không muốn đợi cho đến khi tệp được xả vào đĩa và sau đó mở tệp.
Vì vậy, tôi thích viết nó vào bảng điều khiển.
Bạn đề xuất điều gì?
Tôi đã thêm tệp app.config
có phần bổ sung được thêm vào, nhưng tôi không thể hiển thị bảng điều khiển kết quả.
Sau đây là cấu hình App.config của tôi:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IProviderService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8081/AP2" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IProviderService" contract="IProviderService" name="WSHttpBinding_IProviderService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Temp\\1.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<param name="Threshold" value="INFO" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
bạn có thể gửi tất cả các cấu hình của bạn? –