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 logging to DB2
Date Sat, 11 Dec 2004 01:12:24 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">
</head>
<body bgcolor="#ffffff" text="#000000">
I've got log4net logging to db2. I thought this could be helpful to
someone.<br>
<br>
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.<br>
Beyond that the table create, <span>connectionType</span> and <span>connectionString</span>
where the only changes<br>
<br>
Thanks <br>
It's a great project<br>
Marc<br>
<br>
CREATE TABLE "<span>myschema</span>.LOG"&nbsp; (<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "ID" INTEGER NOT
NULL&nbsp;&nbsp; GENERATED ALWAYS AS IDENTITY (&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
START WITH +1&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
INCREMENT BY +1&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
MINVALUE +1&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
MAXVALUE +2147483647&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
NO CYCLE&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
NO CACHE&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
NO ORDER ) , <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "DATE" TIMESTAMP
NOT NULL , <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "THREAD" VARCHAR(255)
NOT NULL, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "LEVEL" <span>VARCHAR</span>(500)
NOT NULL, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "LOGGER" VARCHAR(255)
NOT NULL, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "MESSAGE" VARCHAR(4000)
NOT NULL, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; "EXCEPTION" VARCHAR(2000)
)&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IN "LRGTABLES" ; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br>
&lt;configuration&gt;<br>
&nbsp; &lt;configSections&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;section name="log4net" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="log4net.Config.Log4NetConfigurationSectionHandler,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
log4net-net-1.0" <br>
&nbsp;&nbsp;&nbsp; /&gt;<br>
&nbsp; &lt;/configSections&gt;<br>
<br>
&nbsp; &lt;log4net&gt;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;logger name="collectEmail"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;level value="DEBUG"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/logger&gt;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;root&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;level value="DEBUG" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;appender-ref ref="LogFileAppender"
/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;appender-ref ref="ConsoleAppender"
/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;appender-ref ref="ADONetAppender"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/root&gt;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;appender name="LogFileAppender" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
type="log4net.Appender.FileAppender" &gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="File" value="c:\\log-file.txt"
/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="AppendToFile" value="true"
/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="Header"
value="[Header]\r\n"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="Footer"
value="[Footer]\r\n"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="ConversionPattern"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
value="%d [%t] %-5p %c [%x]&nbsp; - %m%n"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!--<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="LevelMin"
value="DEBUG" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="LevelMax"
value="WARN" /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/filter&gt;&nbsp;&nbsp;&nbsp;
--&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/appender&gt;<br>
<br>
&nbsp;&nbsp;&nbsp; &lt;appender name="ConsoleAppender" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
type="log4net.Appender.ConsoleAppender" &gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="ConversionPattern"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
value="%d [%t] %-5p %c [%x]&nbsp; - %m%n" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/appender&gt;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &lt;appender name="ADONetAppender"
type="log4net.Appender.ADONetAppender"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;bufferSize value="1" /&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;connectionType value="IBM.Data.DB2.DB2Connection,IBM.Data.DB2,
Version=8.1.2.1" /&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;connectionString value="server=192.168.0.0;database=dbuser;user
Id=username;password=password;persist security info=true" /&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;commandText value="INSERT INTO CNTMGR.Log
(Date,Thread,Level,Logger,Message,Exception) VALUES (@log_date,
@thread, @log_level, @logger, @message, @exception)" /&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@log_date"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="DateTime"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.RawTimeStampLayout"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@thread"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="String"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;size value="255" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&lt;conversionPattern value="%thread" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@log_level"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="String"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;size value="500" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&lt;conversionPattern value="%level" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@logger"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="String"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;size value="255" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&lt;conversionPattern value="%logger" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@message"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="String"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;size value="4000" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&lt;conversionPattern value="%m" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;parameterName value="@exception"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;dbType value="String"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;size value="2000" /&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.ExceptionLayout"
/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br>
&lt;/appender&gt;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;/log4net&gt;<br>
&lt;/configuration&gt;<br>
<div class="moz-signature"><br>
&nbsp; <br>
<p><span style="font-family: Arial;">.</span></p>
</div>
</body>
</html>

Mime
View raw message