logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: logging to DB2
Date Wed, 15 Dec 2004 15:28:37 GMT
Marc,

Thanks for the schema and config.
Can you tell me which version of db2 you have this working on? 

Many thanks,
Nicko

> -----Original Message-----
> From: M. d'Entremont [mailto:mdent@crm3.com] 
> Sent: 11 December 2004 01:12
> To: Log4NET User
> Subject: logging to DB2
> 
> I've got log4net logging to db2. I thought this could be 
> helpful to someone.
> 
> Note: The level field was slightly problematic as it was 
> initially 50 varchars, but log4net seems to send the whole 
> string even when larger then 50. It therefore produced a 
> right truncation error.
> Beyond that the table create, connectionType and 
> connectionString where the only changes
> 
> Thanks
> It's a great project
> Marc
> 
> CREATE TABLE "myschema.LOG"  (
>           "ID" INTEGER NOT NULL   GENERATED ALWAYS AS IDENTITY (  
>             START WITH +1  
>             INCREMENT BY +1  
>             MINVALUE +1  
>             MAXVALUE +2147483647  
>             NO CYCLE  
>             NO CACHE  
>             NO ORDER ) , 
>           "DATE" TIMESTAMP NOT NULL , 
>           "THREAD" VARCHAR(255) NOT NULL, 
>           "LEVEL" VARCHAR(500) NOT NULL, 
>           "LOGGER" VARCHAR(255) NOT NULL, 
>           "MESSAGE" VARCHAR(4000) NOT NULL, 
>           "EXCEPTION" VARCHAR(2000) )   
>          IN "LRGTABLES" ;         
>          
>          
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <configSections>
>     <section name="log4net" 
>       type="log4net.Config.Log4NetConfigurationSectionHandler,
>             log4net-net-1.0" 
>     />
>   </configSections>
> 
>   <log4net>
>     
>     <logger name="collectEmail">
>       <level value="DEBUG"/>
>     </logger>
>     
>     <root>
>       <level value="DEBUG" />
>       <appender-ref ref="LogFileAppender" />
>       <appender-ref ref="ConsoleAppender" />
>        <appender-ref ref="ADONetAppender" />
>     </root>
>     
>     <appender name="LogFileAppender" 
>              type="log4net.Appender.FileAppender" >
>       <param name="File" value="c:\\log-file.txt" />
>       <param name="AppendToFile" value="true" />
>       <layout type="log4net.Layout.PatternLayout">
>         <param name="Header" value="[Header]\r\n"/>
>         <param name="Footer" value="[Footer]\r\n"/>
>         <param name="ConversionPattern" 
>            value="%d [%t] %-5p %c [%x]  - %m%n"
>          />
>       </layout>
>       <!--
>       <filter type="log4net.Filter.LevelRangeFilter">
>         <param name="LevelMin" value="DEBUG" />
>         <param name="LevelMax" value="WARN" />
>       </filter>    -->
>     </appender>
> 
>     <appender name="ConsoleAppender" 
>               type="log4net.Appender.ConsoleAppender" >
>       <layout type="log4net.Layout.PatternLayout">
>         <param name="ConversionPattern" 
>            value="%d [%t] %-5p %c [%x]  - %m%n" 
>         />
>       </layout>
>     </appender>
>     
>     <appender name="ADONetAppender" 
> type="log4net.Appender.ADONetAppender">
>     <bufferSize value="1" />
>     <connectionType 
> value="IBM.Data.DB2.DB2Connection,IBM.Data.DB2, Version=8.1.2.1" />
>     <connectionString 
> value="server=192.168.0.0;database=dbuser;user 
> Id=username;password=password;persist security info=true" />
>     <commandText value="INSERT INTO CNTMGR.Log 
> (Date,Thread,Level,Logger,Message,Exception) VALUES 
> (@log_date, @thread, @log_level, @logger, @message, @exception)" />
>     <parameter>
>         <parameterName value="@log_date" />
>         <dbType value="DateTime" />
>         <layout type="log4net.Layout.RawTimeStampLayout" />
>     </parameter>
>     <parameter>
>         <parameterName value="@thread" />
>         <dbType value="String" />
>         <size value="255" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%thread" />
>         </layout>
>     </parameter>
>     <parameter>
>         <parameterName value="@log_level" />
>         <dbType value="String" />
>         <size value="500" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%level" />
>         </layout>
>     </parameter>
>     <parameter>
>         <parameterName value="@logger" />
>         <dbType value="String" />
>         <size value="255" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%logger" />
>         </layout>
>     </parameter>
>     <parameter>
>         <parameterName value="@message" />
>         <dbType value="String" />
>         <size value="4000" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%m" />
>         </layout>
>     </parameter>
>     <parameter>
>         <parameterName value="@exception" />
>         <dbType value="String" />
>         <size value="2000" />
>         <layout type="log4net.Layout.ExceptionLayout" />
>     </parameter>
> </appender>
>     
>   </log4net>
> </configuration>
> 
> 
>   
> 
> 
> .
> 
> 

Mime
View raw message