log4net ã§ãã°ã¬ãã«æ¯ã«åºåå ãæå®ãã
ç¾å¨ã®ããã¸ã§ã¯ãã§ã¯ãlog4net ã使ç¨ãã¦ãã°ãåºåãããã¨ã«ãªã£ã¦ããã
ãã°ãã¡ã¤ã«åã¯æ¥ä»ã«ãã£ã¦å¤ãããããã®æ¥ã®ãã¹ã¦ã®ãã°ãï¼ã¤ã®ãã¡ã¤ã«ã«åºåãããã
ããæããã°ã¬ãã«æ¯ã«åºåå
ã®ãã¡ã¤ã«ãå¤æ´ã§ããã°ä¾¿å©ãããªããï¼ã¨ææãããã
確ãã«ãã¨æã£ã¦ãããã調ã¹ã¦ã¿ãããã©ããè¦ã¤ããããªãã
ãããªãã°ãã¨æ¬å®¶ã®ãµã¤ããè¦ã¦ã¿ãããã£ããè¦ã¤ãã£ãã
ãã¼ã«ãªãã®ã¯ log4net.Filter.LevelRangeFilter ã¨ãããã£ã«ã¿ã¯ã©ã¹ã
ããã¤ã«åºåããããã°ã¬ãã«ã®ç¯å²ãæå®ãã¦ããã°ã¬ãã«æ¯ã«ã¢ãã³ããè¨å®ãã¦ããã°ããã
DEBUGã»INFOã»ERROR ã§åºåãã¡ã¤ã«ãåãã¦ã¿ãã
ここã«Windowsã¢ããªã®ã½ã¼ã¹ãç½®ãã¦ããã
ãã®ã¢ããªã§ã¯ãFormä¸ã®ãã¿ã³ãæ¼ãã¨ãã°ã¬ãã«å¥ã«ãã°ãåºåãããã
ã¢ããªã±ã¼ã·ã§ã³æ§æãã¡ã¤ã«ã¯ãããªæãã
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> </configSections> <log4net> <appender name="DebugAppender" type="log4net.Appender.FileAppender"> <param name="File" value="C:\log\Debug.log" /> <param name="AppendToFile" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="DEBUG" /> <levelMax value="DEBUG" /> </filter> </appender> <appender name="InfoAppender" type="log4net.Appender.FileAppender"> <param name="File" value="C:\log\Info.log" /> <param name="AppendToFile" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="INFO" /> <levelMax value="INFO" /> </filter> </appender> <appender name="ErrorAppender" type="log4net.Appender.FileAppender"> <param name="File" value="C:\log\Error.log" /> <param name="AppendToFile" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" /> </layout> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="ERROR" /> <levelMax value="ERROR" /> </filter> </appender> <root> <level value="DEBUG" /> <appender-ref ref="DebugAppender" /> <appender-ref ref="InfoAppender" /> <appender-ref ref="ErrorAppender" /> </root> </log4net> </configuration>