分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
log4net可以轻易的将信息日志写入文本,但是无论记录在哪里终究还是为了后期发现问题,维护所用。所以为了查询方便,可以将其配置输出至数据库(Oracle)。
一、插入系统默认字段
首先建库,sql如下:
- --Createtable
- createtableSYSTEMLOG
- (
- log_idNUMBERnotnull,
- log_dateDATE,
- log_levelVARCHAR2(255),
- log_identityVARCHAR2(255),
- log_messageVARCHAR2(4000),255); color:inherit; line-height:20px; font-size:18px; list-style-position:outside!important"> log_exceptionVARCHAR2(4000),92); line-height:20px; font-size:18px; list-style-position:outside!important"> log_loggerVARCHAR2(255),255); color:inherit; line-height:20px; font-size:18px; list-style-position:outside!important"> log_sourceVARCHAR2(1000),)--Createsequence
- sequenceSYSTEMLOG_SEQ
- minvalue1
- maxvalue999999999
- startwith8061
- incrementby1
- cache20;
- <?xmlversion="1.0"encoding="utf-8"?>
- <configuration>
- log4net>
- configSectionssectionname="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
- </appendername="ADONetAppender"type="log4net.Appender.ADONetAppender"bufferSizevalue="1"/>
- connectionTypevalue="Oracle.DataAccess.Client.OracleConnection,Oracle.DataAccess,Version=2.111.7.20,Culture=neutral,PublicKeyToken=89b483f429c47342"connectionStringvalue="DataSource=//59.74.137.215:1521/GSGLAQYJ;UserID=GSGLAQYJ;Password=GSGLAQYJ;"commandTextvalue="INSERTINTOLOG4NET(LOG_ID,LOG_DATE,LOG_LEVEL,LOG_IDENTITY,LOG_MESSAGE,LOG_EXCEPTION,LOG_LOGGER,LOG_SOURCE)VALUES(LOG4NET_SEQ.nextval,:log_date,:log_level,:log_identity,:log_message,:log_exception,:logger,:source)"parameterparameterNamevalue=":log_date"dbTypevalue="DateTime"layouttype="log4net.Layout.RawTimeStampLayout"layoutparameterNamevalue=":log_level"dbTypevalue="String"sizevalue="10"layouttype="log4net.Layout.PatternLayout"conversionPatternvalue="%level"parameterNamevalue=":log_identity"sizevalue="100"conversionPatternvalue="%identity"parameterNamevalue=":log_message"sizevalue="4000"conversionPatternvalue="%m"parameterNamevalue=":log_exception"conversionPatternvalue="%exception"parameterNamevalue=":logger"sizevalue="255"conversionPatternvalue="%logger"parameterNamevalue=":source"sizevalue="1000"conversionPatternvalue="%file:%line"appenderappendername="InfoAppender"type="log4net.Appender.RollingFileAppender"paramname="File"value="Log\\LogInfo\\"paramname="AppendToFile"value="true"paramname="MaxFileSize"value="10240"paramname="MaxSizeRollBackups"value="100"paramname="StaticLogFileName"value="false"paramname="DatePattern"value="yyyyMMdd".log""paramname="RollingStyle"value="Date"paramname="ConversionPattern"value="%n日志时间:%d[%t]%n日志级别:%-5p%n日志类:%c[%x]%n%m%n"
- <!--loggername="loginfo"levelvalue="INFO"appender-refref="InfoAppender"logger>--rootlevelvalue="All"appender-refref="ADONetAppender">