can't use logging to db because timestamp parameter is invalid

Topics: Logging Application Block
May 20, 2008 at 8:16 PM
Edited May 20, 2008 at 8:19 PM
Hello, I'm trying to use the logging application block.

However Logs aren't saved because the application block calls the WriteLog StoredProcedure with an invalid timestamp parameter:

exec WriteLog @eventID=1,@priority=1,@severity=N'Information',@title=N'',@timestamp='2008-05-20 18:42:04.9530000', [snip]

My SQL Server 2008 CTP does not recognize that timestamp due to the many trailing zeroes:

"Error converting data type varchar to datetime" @timestamp='2008-05-20 18:42:04.953' would work...

guess this is a configuration issue?
I have confirmed that select convert(datetime, '2008-05-20 18:42:04.953000') throws an error in both Sql 2008 and 2005 so I don't think it's an SQL 2008 Problem.

Also on a german server '2008-05-20 18:42:04.953' doesn't get recognized either, so I'd prefer the application block to just use the iso 8601 format with only milliseconds precision:

'2008-05-20T18:42:04.953'

Is that possible to configure somehow?
Formatting the timestamp for the @formattedmessage is quite easy <formatters> <add template="Timestamp: {timestamp(yyyy-MM-dd HH:mm:ss.ff) but so far I haven't been able to find a similar option for the other paramters.

Thanks, Ben
May 20, 2008 at 9:08 PM
Edited May 20, 2008 at 9:42 PM
Edit: deleted misinformation :)
May 20, 2008 at 9:47 PM
Nevermind, turns out that datetimes just appear like that in Sql Profiler. When you copy the output directly from profiler into SQL Management Studio, you get the "Error converting data type varchar to datetime" error.

This just distracted me from the real poblem, which was just a typo in the AddLogCategory stored procedure...

Ben

May 20, 2008 at 10:24 PM
Nevermind, turns out that datetimes just appear like that in Sql Profiler. When you copy the output directly from profiler into SQL Management Studio, you get the "Error converting data type varchar to datetime" error.

This just distracted me from the real poblem, which was just a typo in the AddLogCategory stored procedure...

Ben

May 12, 2009 at 1:42 PM

Actually, I have the same problem! bschwehn, how did you solve it?

May 12, 2009 at 1:58 PM

Javas,

for me the problem was just that copying from the profiler log into a query doesn't work. So I'm not sure that you do have the same problem. If so, don't copy from the profiler w/o removing the trailing zeros :)

As for the root cause of what entlib wouldn't log, I just had a bug in my AddLogCategory stored procedure, the profiler timestamp problem just confused me enough to not look at the right place. Had nothing to do with entlib or timestamps.

Benjamin Schwehn

 

May 12, 2009 at 2:23 PM
Benjamin,
  i think, that i have problems exactly with Writelog, because i couldn't find any invokes of AddLog using Profiler, so i think that I have only one problem with a date conversion because no one record goes to the dbo.Log. Do you have any idea how to solve this problem?
---
declare @p14 int
set @p14=NULL
exec WriteLog @eventID=8,@priority=20,@severity=N'Error',@title=N'title',@timestamp='2009-05-12 13:15:25.9070000',@machineName=N'NAME',@AppDomainName=N'797a82aa-7-128866076964390000',@ProcessID=N'4544',@ProcessName=N'C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE',@ThreadName=NULL,@Win32ThreadId=N'7464',@message=N'HandlingInstanceID: cbae1f38-d883-4611-814a-a2efd6fd53f8
An exception of type ''System.Net.WebException'' occurred and was caught.
---
Pavel

On Tue, May 12, 2009 at 4:59 PM, bschwehn <notifications@codeplex.com> wrote:

From: bschwehn

Javas,

for me the problem was just that copying from the profiler log into a query doesn't work. So I'm not sure that you do have the same problem. If so, don't copy from the profiler w/o removing the trailing zeros :)

As for the root cause of what entlib wouldn't log, I just had a bug in my AddLogCategory stored procedure, the profiler timestamp problem just confused me enough to not look at the right place. Had nothing to do with entlib or timestamps.

Benjamin Schwehn

 

Read the full discussion online.

To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)

To start a new discussion for this project, email entlib@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com