上文中講到配置日志模塊的第二步,這篇文章繼續給大家介紹日志配置方法。
Step 3.在</configSections>後加入:(注意,以下配置與Step 2中的sectionGroup一一對應)
代碼
<IsLine.AppLog.Configuration>
<FileRender>
<AppenderStyle>File</AppenderStyle>
<AppenderType>Text</AppenderType>
<AppenderInf>IsLineLog/Log4Net1.txt</AppenderInf>
<AppenderContent>->Event Date:@eventDate;->Level:@level;- >Message:@exception;->Source:@source;->Stack Trace:@StackTrace- >Trigger:@trigger;->Memo:@message</AppenderContent>
<LayoutInf></LayoutInf>
<Level>Debug</Level>
</FileRender>
<OracleUsingSPRender>
<AppenderStyle>Oracle</AppenderStyle>
<AppenderType>StoredProcedure</AppenderType>
<AppenderInf>IsLine.Data.Configuration.OracleConnectString</AppenderInf>
<AppenderContent>SP_ADD_ILFWLOG.ADD_ILFWLOG</AppenderContent>
<LayoutInf></LayoutInf>
<Level>Debug</Level>
</OracleUsingSPRender>
<OracleUsingTextRender>
<AppenderStyle>Oracle</AppenderStyle>
<AppenderType>Text</AppenderType>
<AppenderInf>add key</AppenderInf> //可以填add key,如果add key不存在則會使 用DataBaseConnection
<AppenderContent>"INSERT INTO IsLineFAppLog ([EventDate],[Level],[Source], [Trigger],[Message],[Exception]) VALUES (@eventDate, @level, @source,@trigger, @message, @exception)" </AppenderContent>
<LayoutInf></LayoutInf> //返回給用戶的樣式
<Level>Debug</Level>
</OracleUsingTextRender>
<SQLServerUsingTextRender>
<AppenderStyle>SQLServer</AppenderStyle>
<AppenderType>Text</AppenderType>
<AppenderInf>add key</AppenderInf> //可以填add key,如果add key不存在則會使 用DataBaseConnection
<AppenderContent>"INSERT INTO IsLineFAppLog ([ILEventDate],[ILLevel],[ILSource], [ILTrigger],[ILMessage],[ILException]) VALUES ('@eventDate', '@level', '@source','@trigger', '@message', '@exception')" </AppenderContent>
<LayoutInf></LayoutInf> //返回給用戶的樣式
<Level>Debug</Level>
</SQLServerUsingTextRender>
<SQLServerUsingSPRender>
<AppenderStyle>SQLServer</AppenderStyle>
<AppenderType>StoredProcedure</AppenderType>
<AppenderInf>add key</AppenderInf> //可以填add key,如果add key不存在則會使 用DataBaseConnection
<AppenderContent>IsLineLogSPRender</AppenderContent>
<LayoutInf></LayoutInf> //返回給用戶的樣式
<Level>Debug</Level>
</SQLServerUsingSPRender>
<MailRender>
<AppenderStyle>Mail</AppenderStyle>
<AppenderType>HTML</AppenderType>
<AppenderInf>收件人</AppenderInf>
<AppenderContent>郵件內容:@eventDate, @level, @source,@trigger, @message, @exception</AppenderContent>
<LayoutInf></LayoutInf> //返回給用戶的樣式
<Level>Debug</Level>
</MailRender>
</IsLine.AppLog.Configuration>