Custom log categories in Plugins " is not a class name or namespace " UE_LOG compile error

I used to have code on my project.
Now I moved all to a plugin inside the Plugins/ folder of the project with its subsecuent changes needed.

I Have a definition of a custom log category on the Module .h and .cpp of my plugin. Before moving files, this category was defined on the main projectName.h, as usual.

On the .h
DECLARE_LOG_CATEGORY_EXTERN(LOG_NAME, Verbose, All);

On the .cpp
DEFINE_LOG_CATEGORY(LOG_NAME);

The rest of the files inside the sources folders (Private, Public) seem to not need the inclussion of “PluginNameModule.h” on every file… (seems like it).
But all the UE_LOGS are now failing. They all say that the LogCategory defined (LOG_NAME) is not a class name or a namespace. And other errors follow.

What’s the best practice here when you are working on a plugin? I saw other plugins and none of them seem to include the module base .h to any file…

I fixed this by including the base header file of the module, which contains the log declaration. But this seems weird, I thought this declaration was general for the whole project

2 Likes

Hi @darkgaze, did you find a better way to defined a log category in a plugin since ?


EDIT: Ok including the header file which declare the log category seems to be the standard way (https://answers.unrealengine.com/questions/862022/issue-declaring-log-category.html). Then I took my inspiration from Engine\Source\Runtime\AIModule\Private\AIModuleLog.h, just 1 dedicated file for my log categories I can include without extra code.