1, log4net separate configuration
Log4net supports multiple formats of log output, I only configure this format to output txt files locally.
<log4net> <root> <appender-ref ref= "Rollingfileappender"/> </root> < Appender name= "Rollingfileappender" type= "log4net. Appender.rollingfileappender "> <param name=" File "value=". \\Data\\Log\\Log.txt "/> <param name=" Appendtofile "value=" true "/> <param name=" Maxsizerollbackups "value=" "/> <param name=" maximumfilesize "value=" 5MB "/> <param name=" Rollingstyle "value=" Size "/> <param name=" Staticlogfilename "value=" true "/> <layout type=" Log4net. Layout.patternlayout "> <param name=" Conversionpattern "value="%n[time]:%d%n[level]:%p%n[content]:%m%n "/> </layout> </appender> </log4net>
2. Common.logging Configuration
<configSections> <sectiongroup name="Common"> <section name="Logging"Type="Common.Logging.ConfigurationSectionHandler, common.logging"/> </sectionGroup> </configSections> <common> <logging> <factorya Dapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, common.logging"> <arg key="Showlogname"Value="true"/> <arg key="Showdatatime"Value="true"/> <arg key=" Level"Value="INFO"/> <arg key="DateTimeFormat"Value="HH:mm:ss:fff"/> </factoryAdapter> </logging> </common>
3, common.logging+log4net+ Common.Logging.Log4Net configuration
When you use the common.logging and log4net log components together, you need to be aware of whether the versions match between components.
Reference: Http://stackoverflow.com/questions/8172623/how-to-configure-logging-in-spring-net-using-log4net
Component Downloads: https://github.com/net-commons/common-logging/tree/2.3.0.RC1
<configSections> <sectiongroup name="Common"> <section name="Logging"Type="Common.Logging.ConfigurationSectionHandler, common.logging"/> </sectionGroup> <section name="log4net"Type="log4net. Config.log4netconfigurationsectionhandler, Log4net"/> </configSections> <common> <logging> <factoryadapter type="common.logging.log4net.log4netloggerfactoryadapter,common.logging.log4net1210"> <arg key="Configtype"Value="INLINE"/> </factoryAdapter> </logging> </common> <log4net> <root> <appender -ref ref="Rollingfileappender"/> </root> <appender name="Consoleappender"Type="log4net. Appender.consoleappender"> <layout type="log4net. Layout.patternlayout"> <conversionpattern value="%date [%thread]%-5level%logger%NDC-%message%newline"/> </layout> </appender> <appender name="Rollingfileappender"Type="log4net. Appender.rollingfileappender"> <param name="File"Value=".. \\Data\\Log\\Log.txt"/> <param name="Appendtofile"Value="true"/> <param name="maxsizerollbackups"Value="Ten"/> <param name="maximumFileSize"Value="5MB"/> <param name="Rollingstyle"Value="Size"/> <param name="Staticlogfilename"Value="true"/> <layout type="log4net. Layout.patternlayout"> <param name="Conversionpattern"Value="%n[time]:%d%n[level]:%p%n[content]:%m%n"/> </layout> </appender> </log4net>
4. Output effect
Common.logging log4net Common.Logging.Log4Net Configuration