Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Event Log - Sorting ExceptionsEvent Log - Sorting Exceptions
Previous
 
Next
New Post
6/4/2009 12:57 PM
 

Hello everyone,

I'm fairly new to DNN.  Recently my boss asked me to look into the EventLog of the production site and find the most common exceptions that were not being handled.  I was able to create a t-sql script to accomplish this, but the only solution I found was to use a cursor.  The problem is that I had to run the OpenXML command on every record.  Another issue I ran into was formatting the XML into one record.  Each XML blob came back as a table because of how the XML is formatted:

<LogProperties>
 <LogProperty>
  <PropertyName>EventQueue.ProcessMessage</PropertyName>
  <PropertyValue>Message Processing Failed</PropertyValue>
 </LogProperty>
    .. more properties
</LogProperties>

Does anyone have a solution that does not require a cursor?  Is anyone good with the OpenXML command and know how to get the results back in one record?

Below is the script.  Modify the select statements at the bottom for desired results.  Of course you could put this into a sproc and handle the results elsewere.

@exceptionTable TABLEDATETIME,NVARCHAR(1000),INT,NVARCHAR(1000),INT,NVARCHAR(1000),INT,NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000),UNIQUEIDENTIFIER,NVARCHAR(1000),NVARCHAR(1000),INT,INT,NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000),NVARCHAR(1000) @idoc INT @doc NVARCHAR(MAX) @createDate DATETIME db_cursor CURSOR FOR LogProperties, LogCreateDate EventLog LogTypeKey LIKE '%Exception' LogCreateDate > '2009-1-01' db_cursor NEXT FROM db_cursor INTO @doc, @createDate @@FETCH_STATUS = 0 EXEC sp_xml_preparedocument @idoc output, @doc;INSERT @exceptionTableSELECT ,MAX(CASE WHEN PropertyName = 'AssemblyVersion' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'PortalID' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'PortalName' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'UserID' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'UserName' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'ActiveTabID' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'ActiveTabName' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'RawURL' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'AbsoluteURL' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'AbsoluteURLReferrer' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'UserAgent' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'DefaultDataProvider' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'ExceptionGUID' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'InnerException' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'FileName' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'FileLineNumber' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'FileColumnNumber' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'Method' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'StackTrace' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'Message' THEN PropertyValue END),MAX(CASE WHEN PropertyName = 'AssemblyVersion' THEN PropertyValue END)FROM OPENXML (@idoc, '/LogProperties/LogProperty',2)WITH(nvarchar(1000),nvarchar(1000) )EXEC sp_xml_removedocument @idoc FETCH NEXT FROM db_cursor INTO @doc , @createDate db_cursor db_cursor * FROM @exceptionTableMAX(CreateDate), PortalName, ActiveTabName, ActiveTabID, RawURL, [Message], InnerException, COUNT(InnerException) as NumberOfOccurrances @exceptionTable BY , PortalName, ActiveTabName, ActiveTabId, RawURL, [Message] BY NumberOfOccurrances DESC

DECLARE

(

CreateDate

AssemblyVersion

PortalID

PortalName

UserID

UserName

ActiveTabID

ActiveTabName

RawURL

AbsoluteURL

AbsoluteURLReferrer

UserAgent

DefaultDataProvider

ExceptionGUID

InnerException

[FileName]

FileLineNumber

FileColumnNumber

Method

StackTrace

[Message]

Source

)

DECLARE

DECLARE

DECLARE

DECLARE

SELECT

FROM

WHERE

AND

OPEN

FETCH

WHILE

BEGIN

 

 

 

 

@createDate

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PropertyName

PropertyValue

 

 

 

END

CLOSE

DEALLOCATE

SELECT

SELECT

 

FROM

GROUP

InnerException

ORDER

 
New Post
6/4/2009 4:50 PM
 
So the script did not fair so well durring the post. Here it is in plain text.

DECLARE @exceptionTable TABLE
(
CreateDate DATETIME,
AssemblyVersion NVARCHAR(1000),
PortalID INT,
PortalName NVARCHAR(1000),
UserID INT,
UserName NVARCHAR(1000),
ActiveTabID INT,
ActiveTabName NVARCHAR(1000),
RawURL NVARCHAR(1000),
AbsoluteURL NVARCHAR(1000),
AbsoluteURLReferrer NVARCHAR(1000),
UserAgent NVARCHAR(1000),
DefaultDataProvider NVARCHAR(1000),
ExceptionGUID UNIQUEIDENTIFIER,
InnerException NVARCHAR(1000),
[FileName] NVARCHAR(1000),
FileLineNumber INT,
FileColumnNumber INT,
Method NVARCHAR(1000),
StackTrace NVARCHAR(1000),
[Message] NVARCHAR(1000),
Source NVARCHAR(1000)
)

DECLARE @idoc INT
DECLARE @doc NVARCHAR(MAX)
DECLARE @createDate DATETIME

DECLARE db_cursor CURSOR FOR
SELECT LogProperties, LogCreateDate
FROM EventLog
WHERE LogTypeKey LIKE '%Exception'
AND LogCreateDate > '2009-1-01'

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @doc, @createDate

WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_xml_preparedocument @idoc output, @doc;

INSERT @exceptionTable

SELECT
@createDate,
MAX(CASE WHEN PropertyName = 'AssemblyVersion' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'PortalID' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'PortalName' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'UserID' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'UserName' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'ActiveTabID' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'ActiveTabName' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'RawURL' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'AbsoluteURL' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'AbsoluteURLReferrer' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'UserAgent' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'DefaultDataProvider' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'ExceptionGUID' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'InnerException' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'FileName' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'FileLineNumber' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'FileColumnNumber' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'Method' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'StackTrace' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'Message' THEN PropertyValue END),
MAX(CASE WHEN PropertyName = 'AssemblyVersion' THEN PropertyValue END)
FROM
OPENXML (@idoc, '/LogProperties/LogProperty',2)
WITH
(
PropertyName nvarchar(1000),
PropertyValue nvarchar(1000)
)
EXEC sp_xml_removedocument @idoc

FETCH NEXT FROM db_cursor INTO @doc , @createDate
END

CLOSE db_cursor
DEALLOCATE db_cursor

SELECT * FROM @exceptionTable

SELECT
MAX(CreateDate), PortalName, ActiveTabName, ActiveTabID, RawURL, [Message], InnerException, COUNT(InnerException) as NumberOfOccurrances
FROM @exceptionTable
GROUP BY
InnerException, PortalName, ActiveTabName, ActiveTabId, RawURL, [Message]
ORDER BY NumberOfOccurrances DESC
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Event Log - Sorting ExceptionsEvent Log - Sorting Exceptions


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out