LogBox : Enterprise Logging & Messaging
5.x
5.x
  • Introduction
  • Intro
    • Introduction
      • What's New With 5.4.0
      • What's New With 5.3.0
      • What's New With 5.0.0
      • What's New With 2.1.0
      • What's New With 2.0.0
      • About This Book
      • Author
  • Getting Started
    • Features at a Glance
    • Installation
      • LogBox Refcard
    • Need For Logging
    • How Does LogBox Work?
      • LogBox
      • Appender
      • Logger
        • Logger Category Inheritance
        • Security Levels
        • Dynamic Appenders
      • Layout
  • Configuration
    • Configuring LogBox
      • LogBox DSL
      • Adding Appenders
      • Adding Categories to Specific Loggin Levels
      • Adding Categories Granularly
      • Configuring The Root Logger
  • Usage
    • Using LogBox
    • Using a Logger Object
      • Can Methods For Performance
      • $toString() and ExtraInfo Argument
    • Appender Properties
      • CFAppender
      • ConsoleAppender
      • DBAppender
      • EmailAppender
      • FileAppender
      • RollingFileAppender
      • ScopeAppender
      • SocketAppender
      • TraceAppender
    • LogBox in a ColdBox Application
      • Configuration Within ColdBox
      • Benefits of using LogBox in a ColdBox application
      • Where is LogBox stored in a ColdBox app?
      • LogBox from the ColdBox Proxy
      • The LogBox Injection DSL
  • Extending LogBox
    • Creating Custom Appenders
      • Helper Methods
      • Instance Members
      • Dealing With Custom Layouts
      • Registering Appenders at Runtime
    • Creating a Custom Layout
      • Instance Members
Powered by GitBook
On this page

Was this helpful?

Edit on Git
Export as PDF
  1. Getting Started
  2. How Does LogBox Work?
  3. Logger

Dynamic Appenders

Each logger object has several methods that you can use in order to interact with the logger's appenders. You can add, remove, clear or list the appenders on a specific logger instance. Below are the methods you can use in the logger class to interact with appenders:

Method

Return Type

Description

hasAppenders()

Boolean

Checks if the logger has any appenders attached to it

getAppenders()

Struct

Returns the map of registered appenders

getAppender(name)

Appender

Return a named appender if it is registered in the logger

appenderExists(name)

Boolean

Checks if a named appender exists in the logger

addAppender(Appender)

void

Register an appender with the logger at runtime

removeAppender(name)

Boolean

Will un-register an appender from this logger

removeAllAppenders()

void

Will try to un-register all appenders from this logger

So you can easily add/remove/check the appenders on any logger at any time.

//Add your own appender at runtime
jms = createObject( "component", "com.appender.JMSAppender" ).init( "JMSAppender", properties );
logger.addAppender( jms );

//log a message to all appenders and to my jms appender:
logger.fatal( "I FAILED MAN!" );

//remove it
logger.removeAppender( "JMSAppender" );
PreviousSecurity LevelsNextLayout

Last updated 7 years ago

Was this helpful?