# About logging

Caplin’s _Core Library_ enables you to generate custom log messages of various severity levels, from anywhere within your application.

Application logging is available via the `[caplin.core.log.Log,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.log.html)` singleton. Messages can be logged at various levels, and filtered by their source. The text of a message can be created using either a fixed string or token replacements. Typically, a class constructor will create a logger with the source set to the class name. This logger will then be used for all logging within the class. For example, in class constructor:

```js
this.log = caplin.core.log.Log.getLogger("my.class.Name");
```

With the above logger created as a class member variable (the source/class name set to "my.class.Name"), messages can be logged throughout the class using a text string, like this:

```js
this.log.warn("a message");
```

…or using token replacements, like this:

```js
this.log.info("Latency: {0}, Queue Size: {1}",  sLatency, sQueueSize);
```

The messages logged will be sent to all registered `[caplin.core.log.Logger,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.logger)s`. Caplin provides two Logger implementations:

* `[caplin.core.log.ConsoleLogger,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.consolelogger)`: A Logger that outputs to the developer console found in most modern browsers.
* `[caplin.core.log.StoreLogger,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.storelogger)`: A Logger that stores log messages into internal arrays

Users can create their own Loggers by implementing the [`caplin.core.log.Logger`,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.logger) interface. Loggers are registered with the logging system using the `[caplin.core.log.Log,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.log.html).register` method:

```js
var oLogger = new caplin.core.log.ConsoleLogger(); // create the logger
caplin.core.log.Log.register(oLogger, "*"); // register logger
```

The second argument to `register()` is a pattern that allows you to filter log messages based on the source of the message. For example: a pattern of "caplin.trading.**" will only receive messages logged within the trading library, "**" will log messages from all sources.

For more information see the [API docs,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/) for the [`caplin.core.log.Log`,opts="nofollow"](https://docs.caplin.com/developer/api/caplin_trader/3/caplin.core.log.log.html) namespace.
