> For the complete documentation index, see [llms.txt](https://www.unrealsharp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.unrealsharp.com/getting-started-and-fundamentals/logging.md).

# Logging

**Define Custom Log Categories**

The `[CustomLog]` attribute is used on a `partial` (and preferably `static`) class to define a custom log category, for the Unreal Engine output log.

The category's API will then generate automatically with methods such as `Log` / `LogWarning` / `LogError` / `LogFatal`.

```csharp
[CustomLog]
public static partial class LogMyFirstLog;

[CustomLog(ELogVerbosity.Verbose)]
public static partial class LogMySecondLog;

// Can also be declared internal
[CustomLog]
internal static partial class LogMyInternalLog;
```

* `LogMyFirstLog`: Defaults to `ELogVerbosity.Display` when no verbosity is specified.
* `LogMySecondLog`: Explicitly uses `ELogVerbosity.Verbose`.

***

**Use the Log Categories**

Here’s an example of how to log with your custom categories:

```csharp
[UClass]
public partial class ALogShowcase : AActor
{
    public ALogShowcase()
    {
        LogMyFirstLog.Log("ALogShowcase constructor executed");
    }

    public override void BeginPlay()
    {
        LogMyFirstLog.Log("BeginPlay executed");
        base.BeginPlay();
    }
}
```

And they will show up like this in the output log in the engine:

```
LogMyFirstLog: Display: ALogShowcase constructor executed
LogMyFirstLog: Display: BeginPlay executed
```
