LogBox : Enterprise Logging & Messaging
7.x
7.x
  • Introduction
    • Contribution Guide
    • Release History
      • What's New With 7.2.0
      • What's New With 7.1.0
      • What's New With 7.0.0
    • Upgrading to LogBox 7
    • 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 Logging Levels
      • Adding Categories Granularly
      • Configuring The Root Logger
  • Usage
    • Using LogBox
    • Using a Logger Object
      • When To Log
      • ExtraInfo Serialization
    • 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
  • Instance Members
  • Utility Methods
  • Logging Methods

Was this helpful?

Edit on GitHub
Export as PDF
  1. Usage

Using a Logger Object

Once you retrieve a logger object from LogBox, you are ready to start sending messages. We already covered how to dynamically add/remove/list/check appenders from a logger, so let's look at the other methods we have available:

Instance Members

Every logger has access to the following public variables:

Property

Description

this.logLevels

A reference to the logbox.system.logging.LogLevels class.

Utility Methods

Method

Description

boolean canLog(numeric level)

Checks if this logger can log a certain type of severity. There is also a can{severity}() method for each severity level.

boolean can{severity}()

Checks if this logger can log a certain type of severity.

void setCategory(category)

Set the category name.

Logger getRootLogger()

Get the root logger.

numeric getLevelMin()

Get the minimum severity level.

void setLevelMin(level)

Set the minimum severity level.

numeric getLevelMax()

Get the maximum severity level.

void setLevelMax(level)

Set the maximum severity level.

Logging Methods

Method

Description

fatal(string message, [any extraInfo=""])

Log a fatal message.

error(string message, [any extraInfo=""])

Log an error message.

warn(string message, [any extraInfo=""])

Log a warning message.

info(string message, [any extraInfo=""])

Log an information message.

debug(string message, [any extraInfo=""])

Log a debug message.

logMessage(string message, numeric severity, [any extraInfo=""])

Log any kind of message.

As you can probably tell, all logging methods take in a message string an a second argument called extraInfo. This extraInfo argument can be anything from a string, a structure, a query or whatever. This way you can send in a complex structure that the appenders will serialize into message form or log into the appropriate channel. Thus, extraInfo can be very handy when you are building your own custom appenders.

// setting some messages
myLogger = logBox.getLogger( this ); // "com.model.dao"

myLogger.info( "I just created my first logger" );

try{
    data = dao.getDBData();
}
catch( any e ){
    myLogger.error(
        "Something really died on my dbdata method: #e.message# #e.detail#",
        e.tagContext
    );
}

I hope that by now you understand the basics of loggers and how easy it is to use them.

PreviousUsing LogBoxNextWhen To Log

Last updated 1 year ago

Was this helpful?