• 1Installation
  • 2Loggers
  • 3Log Information
  • 4Configuration
  • 5Logging Appender
  • 6Custom Appender
  • 7Async Logging
  • 8Custom Async Appender

Log.apex

  • Docs
  • Tutorials
Getting started with Log.apex

Custom Appender

You can create your own appenders. All appenders should implement the interface Log.Appender. To make things simple, most of the time you can directly extend Log.DefaultAppender to create a custom appender.

public class CustomAppender extends Log.DefaultAppender {
    public override void append(Log.Context ctx) {
        String message = ctx.message;
        String pattern = (String)this.options.get('pattern');
        // Custom code
    }
}

Then you can add it to the configuration file.

[
    {
        "patterns": [ ".*" ],
        "level": "Debug",
        "appenders": [
            {
                "name": "CustomAppender",
                "options": {
                    "pattern": "YOUR PATTERN"
                }
            }
        ]
    }
]

You can set options to your custom appender like this.

Done