I tried to recreate your problem on my local machine using your configuration. I agree with Ron; your config is fine. I don't see the same truncation problem, though.
Maybe this is a silly question, but have you double-checked the database fields? Are you perhaps running with ANSI_WARNINGS off? I ask because log4net will complain about database field truncation unless the ANSI_WARNINGS are off. Then, insertion commands that truncate will be allowed to execute, no matter where they are from. Out of curiosity, have you tried performing an insert manually? -Ross On Tue, May 11, 2010 at 3:58 AM, Watson, Gary <gary.wat...@nustarenergy.com>wrote: > I hadn't noticed v1.0 being used, but after replacing that with v2.0, it > makes no difference. I have even tried using a stored procedure instead, > replacing the commandText value with the SP name, and setting commandType as > "StoredProcedure", but it is still truncating. > > -----Original Message----- > From: Ron Grabowski [mailto:rongrabow...@yahoo.com] > Sent: 11 May 2010 01:57 > To: Log4NET User > Subject: Re: AdoNetAppender field sizes > > The config looks correct to me. Are you sure you want to use the .NET 1.0 > version of System.Data? Does this make a difference? > > <connectionTypevalue="System.Data.SqlClient.SqlConnection, System.Data" /> > > > > ----- Original Message ---- > From: "Watson, Gary" <gary.wat...@nustarenergy.com> > To: "log4net-user@logging.apache.org" <log4net-user@logging.apache.org> > Sent: Mon, May 10, 2010 8:19:48 AM > Subject: AdoNetAppender field sizes > > Hello, > > I am using the AdoNetAppender in log4net to write error messages to a SQL > Server 2000 database. Here is the configuration I am using, taken from my > app.config file: > > <configSections> > <section name="log4net" > type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> > </configSections> > <log4net> > <appender name="ADONetAppender" type="log4net.Appender.ADONetAppender"> > <bufferSize value="1" /> > <connectionType value="System.Data.SqlClient.SqlConnection, > System.Data, Version=1.0.3300.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089" /> > <connectionString value="Data Source=MHL1\SQL2000;Initial > Catalog=Stocks;Integrated Security=true;" /> > <commandText value="INSERT INTO Log > ([Date],[Thread],[Level],[Logger],[Message],[Exception],[Context],[Username]) > VALUES > (@log_date, @thread, @log_level, @logger, @message, @exception, > @context, @username)" /> > <parameter> > <parameterName value="@log_date" /> > <dbType value="DateTime" /> > <layout type="log4net.Layout.RawTimeStampLayout" /> > </parameter> > <parameter> > <parameterName value="@thread" /> > <dbType value="String" /> > <size value="32" /> > <layout type="log4net.Layout.PatternLayout"> > <conversionPattern value="%t" /> > </layout> > </parameter> > <parameter> > <parameterName value="@log_level" /> > <dbType value="String" /> > <size value="512" /> > <layout type="log4net.Layout.PatternLayout"> > <conversionPattern value="%p" /> > </layout> > </parameter> > <parameter> > <parameterName value="@context" /> > <dbType value="String" /> > <size value="512" /> > <layout type="log4net.Layout.PatternLayout"> > <conversionPattern value="%x" /> > </layout> > </parameter> > <parameter> > <parameterName value="@logger" /> > <dbType value="String" /> > <size value="512" /> > <layout type="log4net.Layout.PatternLayout"> > <conversionPattern value="%c" /> > </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> > <parameter> > <parameterName value="@username" /> > <dbType value="String" /> > <size value="8" /> > <layout type="log4net.Layout.PatternLayout"> > <conversionPattern value="%X{username}" /> > </layout> > </parameter> > </appender> > <root> > <level value="ALL" /> > <appender-ref ref="ADONetAppender" /> > </root> > </log4net> > > > I have created the "Log" table as referenced in the "CommandText" property > with fields having the same names and sizes for each of the parameters. As > you can see, the "@exception" parameter has a specified size of 2000 > characters. However, the "Exception" values that are stored in the table > after errors occur appear to be truncated at 256 characters. > > The code I am using to configure log4net is as follows: > > log4net.Config.XmlConfigurator.Configure() > Dim h As log4net.Repository.Hierarchy.Hierarchy = > CType(LogManager.GetRepository(), Repository.Hierarchy.Hierarchy) > Dim ado As Appender.AdoNetAppender = > CType(h.Root.GetAppender("ADONetAppender"), Appender.AdoNetAppender) > ado.ConnectionString = CGlobals.log4netConnectionString > ado.ActivateOptions() > log4net.GlobalContext.Properties("username") = Environment.UserName > > And when storing the error, here is the code that I use: > > Using log4net.NDC.Push(sContext) > Dim l4nLog As ILog = > LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) > l4nLog.Error(sMessage) > End Using > > Can anybody shed some light as to why this is happening? I am not > truncating anything in code, and also cannot see anything in the log4net > source to indicate that this would be happening there either. > > Thanks, > Gary > > ______________________________________________________________________ > This e-mail has been scanned by MCI Managed Email Content Service, using > Skeptic(tm) technology powered by MessageLabs. For more information on MCI's > Managed Email Content Service, visit http://www.mci.com. > ______________________________________________________________________ >