반응형
프로젝트의 App.config 파일에 log4net 설정 추가
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="ConsoleLog" />
</root>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<file value="Log\" />
<datePattern value="yyyy-MM-dd'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss.fff} [%thread] %-5level %logger : %message %newline" />
<conversionPattern value="%date{HH:mm:ss.fff} [%thread] %-5level : %message %newline" />
</layout>
</appender>
<appender name="ConsoleLog" type="log4net.Appender.ConsoleAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<level value="INFO" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date{HH:mm:ss.fff} [%thread] %-5level : %message [%stacktrace{level}]%newline" />
<param name="ConversionPattern" value="%date{HH:mm:ss.fff} [%thread] %-5level : %message%newline" />
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
소수인지 여부 확인 (0) | 2021.02.18 |
---|---|
Hashtable & Dictionary Example (0) | 2021.02.17 |
Visual Studio color schemes (0) | 2021.02.10 |
C# DatagridView 조건에 따라 Cell 속성 변경 (0) | 2021.02.09 |
C# Winform Datagridview Style 적용 (0) | 2021.02.09 |