Common.logging log4net Common.Logging.Log4Net Configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.