I have also run into the same issue today and have probably found the solution to your issue. Let’s look at the example of LogTemp:
CoreGlobals.h:
CORE_API DECLARE_LOG_CATEGORY_EXTERN(LogTemp, Log, All);
CoreGlobals.cpp:
DEFINE_LOG_CATEGORY(LogTemp);
You actually do include the CoreGlobals in any of your headers as long as you #include "CoreMinimal.h" which in return includes CoreGlobals.h. Thus, you can use LogTemp anywhere.
The key to being able to use your custom log category in other modules but the one where it is defined in, however, seems to be the CORE_API directive right before you declare the log temp category. Without it it is not possible to use the log category in another module (Though it might be possible to redefine DEFINE_LOG_CATEGORY(LogTemp) in your second module, but that should be avoided I feel).
So your declaration could look like:
MyLogCategory.h
MYGAME_API DECLARE_LOG_CATEGORY_EXTERN(LogMyGameLog, Log, All);
MyLogCategory.cpp
DEFINE_LOG_CATEGORY(LogMyGameLog);
Beware, you still need to include the header, in which the category is defined, in the class where you want to use the category.
MyCategoryUserInMyOtherModule.cpp
#include "MyGame/MyLogCategory.h"
AND obviously you need to set up the dependency to the category’s module in the other module where you wanna use it. That happens in the PublicDependencyModuleNames in your MyOtherModule.Build.cs.
PublicDependencyModuleNames.AddRange(new string[] { "Core", "MyGame" });
It is possible to define the category in your module’s class, too, such as:
MyGame.h
MYGAME_API DECLARE_LOG_CATEGORY_EXTERN(LogMyGameLog, Log, All);
MyGame.cpp
DEFINE_LOG_CATEGORY(LogMyGameLog);
But you will still need to #include "MyGame/MyGame.h" and have the dependency set correctly ofc.