Log.apex

  • Docs
  • Tutorials
Docs Menu
  • Logger
  • Configuration
    • Configuration File
    • Configure Logging
  • Appenders
    • Default Appenders
    • Custom Appenders
    • Async Logging
    • Default Async Appenders
    • Custom Async Appenders

Custom Async Appenders Guide

Custom Async Appenders

Custom Appender

You can create a custom async appender in two ways:

  • Implement Log.AsyncAppenderExample:
public class CustomAsyncAppender implements Log.AsyncAppender {
    private Map options;
    private List contexts = new List();

    public void setOptions(Map options) {
        this.options = options;
    }

    public void append(Context ctx) {
        this.contexts.add(ctx);
    }

    public void flush() {
        // Custom code
    }
}
  • Extend Log.DefaultAsyncAppenderExample:
public class CustomAsyncAppender extends Log.DefaultAsyncAppender {
    public override void flush() {
        for(Log.Context ctx : this.contexts) {
            String message = ctx.message;
            // Custom code
        }
    }
}

Contribute on Github! Edit this section.