logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "M. d'Entremont" <md...@crm3.com>
Subject Re: logging to DB2
Date Wed, 15 Dec 2004 20:40:05 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
DB2 8.2, a.k.a Stinger<br>
<br>
It's their most recent to date. Pretty much every thing should be
similar on old versions with slight syntactic changes<br>
<br>
Marc<br>
<br>
Nicko Cadell wrote:
<blockquote
 cite="midDDEB64C8619AC64DBC074208B046611C59C77F@kronos.neoworks.co.uk"
 type="cite">
  <pre wrap="">Marc,

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

Many thanks,
Nicko

  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: M. d'Entremont [<a class="moz-txt-link-freetext" href="mailto:mdent@crm3.com">mailto:mdent@crm3.com</a>]

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" ;         
         
         
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;configuration&gt;
  &lt;configSections&gt;
    &lt;section name="log4net" 
      type="log4net.Config.Log4NetConfigurationSectionHandler,
            log4net-net-1.0" 
    /&gt;
  &lt;/configSections&gt;

  &lt;log4net&gt;
    
    &lt;logger name="collectEmail"&gt;
      &lt;level value="DEBUG"/&gt;
    &lt;/logger&gt;
    
    &lt;root&gt;
      &lt;level value="DEBUG" /&gt;
      &lt;appender-ref ref="LogFileAppender" /&gt;
      &lt;appender-ref ref="ConsoleAppender" /&gt;
       &lt;appender-ref ref="ADONetAppender" /&gt;
    &lt;/root&gt;
    
    &lt;appender name="LogFileAppender" 
             type="log4net.Appender.FileAppender" &gt;
      &lt;param name="File" value="c:\\log-file.txt" /&gt;
      &lt;param name="AppendToFile" value="true" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;param name="Header" value="[Header]\r\n"/&gt;
        &lt;param name="Footer" value="[Footer]\r\n"/&gt;
        &lt;param name="ConversionPattern" 
           value="%d [%t] %-5p %c [%x]  - %m%n"
         /&gt;
      &lt;/layout&gt;
      &lt;!--
      &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
        &lt;param name="LevelMin" value="DEBUG" /&gt;
        &lt;param name="LevelMax" value="WARN" /&gt;
      &lt;/filter&gt;    --&gt;
    &lt;/appender&gt;

    &lt;appender name="ConsoleAppender" 
              type="log4net.Appender.ConsoleAppender" &gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;param name="ConversionPattern" 
           value="%d [%t] %-5p %c [%x]  - %m%n" 
        /&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
    
    &lt;appender name="ADONetAppender" 
type="log4net.Appender.ADONetAppender"&gt;
    &lt;bufferSize value="1" /&gt;
    &lt;connectionType 
value="IBM.Data.DB2.DB2Connection,IBM.Data.DB2, Version=8.1.2.1" /&gt;
    &lt;connectionString 
value="server=192.168.0.0;database=dbuser;user 
Id=username;password=password;persist security info=true" /&gt;
    &lt;commandText value="INSERT INTO CNTMGR.Log 
(Date,Thread,Level,Logger,Message,Exception) VALUES 
(@log_date, @thread, @log_level, @logger, @message, @exception)" /&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@log_date" /&gt;
        &lt;dbType value="DateTime" /&gt;
        &lt;layout type="log4net.Layout.RawTimeStampLayout" /&gt;
    &lt;/parameter&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@thread" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
            &lt;conversionPattern value="%thread" /&gt;
        &lt;/layout&gt;
    &lt;/parameter&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@log_level" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="500" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
            &lt;conversionPattern value="%level" /&gt;
        &lt;/layout&gt;
    &lt;/parameter&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@logger" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
            &lt;conversionPattern value="%logger" /&gt;
        &lt;/layout&gt;
    &lt;/parameter&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@message" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="4000" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
            &lt;conversionPattern value="%m" /&gt;
        &lt;/layout&gt;
    &lt;/parameter&gt;
    &lt;parameter&gt;
        &lt;parameterName value="@exception" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="2000" /&gt;
        &lt;layout type="log4net.Layout.ExceptionLayout" /&gt;
    &lt;/parameter&gt;
&lt;/appender&gt;
    
  &lt;/log4net&gt;
&lt;/configuration&gt;


  


.


    </pre>
  </blockquote>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="Content-Type" content="text/html; ">
<title>Marc d&#8217;Entremont</title>
<table width="100%">
  <tbody>
    <tr>
      <td align="left"><span style="font-family: Arial;">Marc
d&#8217;Entremont</span></td>
      <td align="left"><span style="font-family: Arial;">Ph: (250)
386-4266</span></td>
    </tr>
    <tr>
      <td align="left"><span style="font-family: Arial;">Convergent
Media Network</span></td>
      <td align="left"><span style="font-family: Arial;">Fax: (250)
386-4267</span></td>
    </tr>
    <tr>
      <td align="left"><span style="font-family: Arial;">210-19 Dallas
Rd.</span></td>
      <td align="left"><span style="font-family: Arial;">Mobile: (250)
886-8665</span></td>
    </tr>
    <tr>
      <td align="left"><span style="font-family: Arial;">Victoria, BC</span></td>
      <td align="left"><span style="font-family: Arial;"><a class="moz-txt-link-abbreviated"
href="mailto:mdent@crm3.com">mdent@crm3.com</a></span></td>
    </tr>
    <tr>
      <td align="left"><span style="font-family: Arial;">V8V 5A6</span></td>
    </tr>
    <tr>
    </tr>
  </tbody>
</table>
<br>
<br>
<span style="font-family: Arial;">&nbsp;</span>
<span style="font-family: Arial;">&nbsp;</span>
&nbsp;
&nbsp;<img src="cid:part1.04000206.00060701@crm3.com" height="136"
 width="418">
&nbsp;
<p><span style="font-family: Arial;">This electronic message
transmission, including any attached files, contains information which
may be
confidential and/or privileged. The information is intended to be for
the SOLE
use of the individual or entity named above. If you are not the
intended
recipient, be aware that any review, disclosure, copying, distribution
or use
of the contents of this information is prohibited.&nbsp; This message is not
to be
forwarded for any reason without prior consent of the sender.</span></p>
<p><span style="font-family: Arial;">If you have received this
electronic transmission in error, please notify the sender immediately
by
telephone (250) 386-4266 or by a "reply to sender only" message and
destroy all electronic and hard copies of the communication, including
attachments, without reading or saving in any manner.</span></p>
</div>
</body>
</html>

Mime
View raw message