Geta

Meny NO

Quick tip: clean up your log file

Is your Episerver log file full of warning messages related to deprecated property types? I prefer keeping my log file clean - in this short blog post I will show you how these messages easily can be removed.

The problem

Recently I noticed quite a lot of warnings in my Episerver log file.
The log message would look similar to this:

WARN EPiServer.DataAbstraction.PropertyDefinitionType: Could not load type 'Demo.SpecializedProperties.MyCustomProperty', falling back to base type 
instead

This would typically happen if the type MyCustomProperty had been moved to another namespace or removed from the code. But since EPiServer still has the old type registered in the system, it will log a warning when the site starts up.

The solution

Open SQL Management Studio and run the following queries against your cms database:

DECLARE @oldPropertyTypeName varchar(100)
SET @oldPropertyTypeName = 'Demo.SpecializedProperties.MyCustomProperty'
SELECT *
FROM tblPropertyDefinitionType
WHERE (TypeName LIKE @oldPropertyTypeName)
Select * from tblPropertyDefinition
where fkPropertyDefinitionTypeID in (
SELECT pkID
FROM tblPropertyDefinitionType
WHERE (TypeName LIKE @oldPropertyTypeName))

The first query will list the property definition (see image below), the second will tell if the property is in use in any content types (it should return 0 rows).

If your second query returns 0 hits it is safe to delete the property definition.

-- Run DELETE statements below if query nr 2 returns 0 hits
DELETE FROM tblPropertyDefinitionType
WHERE (TypeName LIKE @oldPropertyTypeName)

This will remove the deprecated type and you will not see more of that annoying warning message.

Note:
If you for some reason get hits for query 2 (could happen if property has changed namespace), the trick is to locate the content type where it is used, navigate to admin mode, go to "Settings" and select the "Revert to default" button. Then try the queries again.

kommentarer drevet av Disqus