I need to run a script to configure a LocalDB (v11.0.3000) instance and database (from a .NET 4.5 program) and I want to record results at various stages. Someone suggested xp_logevent but it doesn't seem to work for me. Should it? When that failed, I tried RAISERROR ... WITH LOG but that didn't work, either. Both write to the SQL Server log but neither write to the Windows Application event log (or any other log that I can see).

Note: although I want to run the script from a program, at this stage, I'm just using Mgmt Studio.

I've tried:

EXEC master..xp_logevent 50001, 'Test'
EXEC master..xp_logevent 50002, 'Test', informational
EXEC master..xp_logevent 50003, 'Test', warning
EXEC master..xp_logevent 50004, 'Test', error


RAISERROR (N'This is message %s %d.', -- Message text.
           10, -- Severity,
           1, -- State,
           N'number', -- First argument.
           5) WITH LOG;

I've tried the same code under SQL Server Express (v11.0.3128) and it worked.

The account I'm using is sysadmin. I've tried it with the account in BUILTIN\Administrators in case that was part of the problem - I know you have to be an admin to create an event source - but it didn't work.

If there's nothing that can be done to get either to work, is there another way of getting output from LocalDB on a client machine? All that will be installed is LocalDB and .NET 4.5.


I've tried this on a second machine, recently upgraded to SQL Express 2012 SP1, and already with LocalDB, and got the same results.

  • Your code works fine on my local R2 installation (W7). I can see the messages in the Event Viewer (Application branch). Before that there was a linked message that said "Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required." and a following one "Using 'xplog70.dll' version '2009.100.1600' to execute extended stored procedure 'xp_logevent'. This is an informational message only; no user action is required.". Do you have them? – Marian May 27 '13 at 9:14
  • I have both 33090 and 8128, but only from the source 'MSSQL$SQLEXPRESS' from when I ran the tests against the SQLEXPRESS instance. There is a source for localDB: 'SQLLocalDB 11.0' but I don't have any such messages from that source. What source did yours come from? – serialhobbyist May 27 '13 at 14:21
  • Mine is "MSSQL$SQL2008R2", so the actual service I've used. – Marian May 27 '13 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.