# log4javascript

# log4javascript 1.4 Lite manual

## Contents

- Introduction
- log4javascript static properties/methods
- Levels
- Loggers
- Enabling / disabling log4javascript Lite

## Introduction

log4javascript Lite is designed to be a basic, lightweight, cross-browser logging tool. It provides functions to log messages of different severity to a pop-up window using the exactly the same syntax as log4javascript. It is designed for situations when the key requirement is just to display logging messages without needing all the features of the standard version of log4javascript.

Below is the complete list of functions and properties available in log4javascript Lite. They make up a small subset of those provided by the standard version of log4javascript. Each function is named and called identically to the equivalent function in log4javascript. Please refer to the log4javascript manual for a detailed explanation of all the concepts alluded to in this document.

Top

## log4javascript static properties/methods

#### Properties

- version
  The version number of your copy of log4javascript.
- edition
  The edition of your copy of log4javascript ("log4javascript_lite" in this case").

#### Methods

- getDefaultLogger
  `Logger getDefaultLogger()`
  Returns the default and only logger (apart from the null logger). The default logger logs to a simple pop-up window.
- getNullLogger
  `Logger getNullLogger()`
  Returns an empty logger. Useful for disabling all logging.
- setEnabled
  `void setEnabled(Boolean enabled)`
  Parameters:
  - `enabled`
  Enables or disables all logging, depending on `enabled`.
- isEnabled
  `Boolean isEnabled()`
  Returns true or false depending on whether logging is enabled.
- setShowStackTraces
  `void setShowStackTraces(Boolean show)`
  Parameters:
  - `show`
  Enables or disables displaying of error stack traces, depending on `show`. By default, stack traces are not displayed. (Only works in Firefox)

Top

## Levels

Levels are available as static properties of the `log4javascript.Level` object. In ascending order of severity:

1. `log4javascript.Level.ALL`
2. `log4javascript.Level.TRACE`
3. `log4javascript.Level.DEBUG`
4. `log4javascript.Level.INFO`
5. `log4javascript.Level.WARN`
6. `log4javascript.Level.ERROR`
7. `log4javascript.Level.FATAL`
8. `log4javascript.Level.NONE`

Top

## Loggers

There are only two loggers in log4javascript Lite: the default logger obtained by calling `log4javascript.getDefaultLogger()` and the empty logger returned by `log4javascript.getNullLogger()`.

#### Logger methods

- setLevel
  `void setLevel(Level level)`
  Parameters:
  - `level`
  Sets the level. Log messages of a lower level than `level` will not be logged. Default value is `ALL` (unlike in log4javascript, where the default level is `DEBUG`).
- getLevel
  `Level getLevel()`
  Returns the level for this logger.
- trace
  `void trace(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `TRACE`.
- debug
  `void debug(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `DEBUG`.
- info
  `void info(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `INFO`.
- warn
  `void warn(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `WARN`.
- error
  `void error(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `ERROR`.
- fatal
  `void fatal(Object message1[, Object message2, ... ][, Error exception])`
  Parameters:
  - `message1[, message2...]`
  - `exception` [optional]
  Logs one or more messages and optionally an error at level `FATAL`.
- isEnabledFor
  `Boolean isEnabledFor(Level level, Error exception)`
  Parameters:
  - `level`
  Returns whether the logger is enabled for the specified level.
- isTraceEnabled
  `Boolean isTraceEnabled()`
  Returns whether the logger is enabled for `TRACE` messages.
- isDebugEnabled
  `Boolean isDebugEnabled()`
  Returns whether the logger is enabled for `DEBUG` messages.
- isInfoEnabled
  `Boolean isInfoEnabled()`
  Returns whether the logger is enabled for `INFO` messages.
- isWarnEnabled
  `Boolean isWarnEnabled()`
  Returns whether the logger is enabled for `WARN` messages.
- isErrorEnabled
  `Boolean isErrorEnabled()`
  Returns whether the logger is enabled for `ERROR` messages.
- isFatalEnabled
  `Boolean isFatalEnabled()`
  Returns whether the logger is enabled for `FATAL` messages.

Top

## Enabling / disabling log4javascript Lite

All logging can be enabled or disabled in log4javascript Lite in a number of ways:

- At any time, you can call `log4javascript.setEnabled(enabled)`. This will enable or disable all logging, depending on whether `enabled` is set to `true` or `false`.
- Assign your logger object a value of `log4javascript.getNullLogger()`.
- Replace your copy of log4javascript_lite.js with stubs/log4javascript_lite.js, provided in the distribution. This file has a stub version of each of the functions and methods in the log4javascript Lite API and can simply be dropped in in place of the main file.

Top