How to print a log from .cs file?

I want to print some logs from .cs files (i.e. [MyGame].Build.cs) but C# is not my strong suit. I tried to use Log.TraceLog() from UnrealBuildTool but I’m getting an error about Log not defined in current context. How to add it to the context?

Log.TraceError worked for me.

Try adding using Tools.DotNETCommon; at the top of your file.