Your Magic log

The log component allows you to browse your server’s log. When an important event occurs in Magic, a log entry will typically be created describing the event. Examples of such events are when users are logging in, or errors are occuring in the system for some reasons. Below you can see a screenshot of how the log component looks like.

Magic log

Notice, as you scroll to the bottom of your log, it will automatically retrieve more items from your backend, giving you the ability to rapidly scroll down to the time period you want to view. Since log items are displayed such that the last item is displayed at the top, this allows you to “browse backwards in time”. You can also create your own log entries in your own Hyperlambda by using code resembling the following.

log.info:Something important happened
   what:Something
   importance:High

In the above example we are creating an “info” type of log entry, and the “Something important happened” will become the item’s sub-type, while the [what] and [importance] parts becomes meta data associated with your log entry. If you execute the above Hyperlambda using your dashboard’s “Eval” component you can see your log entry in your “Log” component at the top afterwards. There exists 4 types of log entries you can create by default.

Your server has a “log level” setting that decides how much it should log. This is an incrementally increasing value starting at “debug” and ending at “off”. The latter implying logging is turned off. You can change this “log level” by changing your magic:logging:level configuration setting. The log level declares at what “level” your server will insert log entries. For instance, typically when debugging you want to set the level at “debug”, while in a production environment you want to increase it to (at least) “info” to avoid flooding your server with debug log entries. This implies that in your debug environment you will see all log entries, including your debug log entries - While in production Magic won’t create log entries for debug log items.

Internals

By default log items will be persisted into your magic “log_entries” database table, but it is possible to persist log items into for instance a NoSQL based database. See how to configure NoSQL logging here. If you use NoSQL logging however, you will not be able to view statistics in your dashboard due to how NoSQL database systems don’t provide (good) mechanisms to aggregate and group data.