Where do I put: DECLARE_LOG_CATEGORY_EXTERN?

Hi guys, I’ve been trying to set up custom logging and I’ve been trying to use this as a guide:

The issue is this doesn’t work for me. I’ve tried putting the custom category in like this:

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#ifndef __THE_BATTLE_OF_MALDON_H__
#define __THE_BATTLE_OF_MALDON_H__

#include "EngineMinimal.h"

DECLARE_LOG_CATEGORY_EXTERN(CombatDecisions, Log, All)
DECLARE_LOG_CATEGORY_EXTERN(CombatCombos, Log, All)
#endif

This fails and the complier has no idea what it is. I’ve also tried putting it straight into the .h of the classes that will be using it and same errors.

Could someone show me an example of exactly where it needs to be in code?

I also need to use DEFINE_LOG_CATEGORY within the .cpp so that would be great to know as well?

They wiki page you linked describes where the code goes, so they must have updated it since this question was asked… This is an older post, but I’ll quickly answer here in case people find this through a search like me:

If you project is called MyGame, do the following:

In MyGame.h

DECLARE_LOG_CATEGORY_EXTERN(MyLogCat, Log, All);

and in MyGame.cpp

DEFINE_LOG_CATEGORY(MyLogCat);

To add onto this, if you’ve defined custom logs, you need to include the base header to use them

1 Like

What is the “base header”? Like MyProject.h?