Log Management

Log Management for the MEAN Stack Framework

Deepa Ramachandra
Deepa Ramachandra

MEAN is evolving as a popular web stack for developing cloud-native applications because of its scalability, ease of extension, and high reliability. Each component in MEAN is built on JavaScript, contributing to a cohesive development platform. In this post, we take you through the log management options that are available for each component of the MEAN stack framework and their respective limitations – limitations that are addressable with a refined log management solution like observIQ. But first, here’s a rundown of the functionality of each of the components in the framework:


MongoDB is an open-source and NoSQL, object-oriented database management system. Using MongoDB as the database for this framework simplifies the movement of objects between the application and the database. The MEAN stack, wholly built on JavaScript, eliminates the need to translate the objects during this movement. MongoDB is highly malleable, and extending the resources of the database is achievable in a few simple steps.


Express serves as the backend of the MEAN stack, facilitating the data and request transfer between the frontend of the application and the database. This is a web framework that is specifically designed for use with Node.js, contributing to a completely JavaScript stack. Using Express declutters the application’s backend with concise request and response structuring from and to the backend.


AngularJS is Google’s JavaScript frontend framework – considered an industry standard for frontend development. Its supreme architecture, code reusability, and plug-and-play components fine-tune the development experience. It offers a highly expressive environment for cross-platform functionalities through a highly integrative HTML and application component framework.


Node.js is an open-source JavaScript framework that uses asynchronous events to process multiple connections simultaneously.

Most applications on the web use Node to process multiple asynchronous events in unison. Its high scalability in handling a constantly increasing volume of requests gives this framework an edge over the other options. It is at the center of a MEAN stack’s framework, serving data quickly and efficiently. Express.js is purpose-built to work with both Node.js and Angular.js.

Existing log management for Node

Node has an expansive logging functionality that is structured using JSON with advanced logging patterns and recorded data fields. Both on-prem and cloud-native Node applications have two logging options; logging to an exportable file or forwarding logs directly to a log management application. Logging Node.js applications is done via third-party logging libraries such as Winston, Pino, and Morgan.

For containerized and orchestrated applications built on the MEAN stack framework, it is recommended to use the console’s transport option to create the path to finally output logs to the container/ orchestrator’s centralized logging location.


Winston is the logging library of choice for most MEAN stack applications. Winston gives the extensibility and flexibility needed to log large application events. Using Winston as your log shipper you can:

  1. Define logging levels based on your application needs. Adding a logging level increases the visibility into severe issues and assists with creating a meaningful categorization for any application activity. By default, Winston logs events based on the npm priority protocol that categorizes logs into six priority levels ranging from 0 to 5, 0 being the most critical and 5 the least in severity. Alternatively, you can set to follow the Syslog protocols.
  2. Winston offers three log transport options, console, file, and HTTP. The term transport is used in Winston to denote the storage and output of logs.
  3. Adding meaningful and diagnostic metadata to your logs both globally and locally. This is a foolproof way to read the fine-grain details of application requests during troubleshooting. For instance, adding the user’s geographic location to access logs helps identify application issues affecting users from specific geography.
  4. Categorization and sub-categorization options for adding more context to logs.
  5. Logging in JSON is always the best way to output your logs for easy parsing into a log management application.
  6. Use Winston’s exception handling library to log application exceptions. Winston does not log exceptions by default.


Pino is a fast logging option for MEAN stack applications. It offers a command-line logging interface that decouples the log processing, alerting, and reformatting into separate processes, to overcome Node’s single-threaded event loop. For faster performance, Pino offers an extreme mode setting. In this mode, logs are written directly to the output stream to increase efficiency. Pino does this in chunks and this is the downside of using Pino because chunk output may result in missing out some logs when there’s downtime or outage.


Morgan simplifies the process of logging HTTP requests. It is a logging library and not a log shipper like Winston. The automatic logging capabilities of Morgan save time for developers by eliminating the need to manually code the application to log all HTTP requests. Morgan logs in the Apache combined log format and it needs Winston to forward the logs to any external application for analysis and log management.

Existing log management for Mongo Logs

By default, MongoDB outputs logs in the JSON format for database events such as entries, commands run, and issues. In container orchestrated applications, MongoDB offers a plethora of options to monitor the cluster. When troubleshooting the log granularity can be fine-tuned to get insights into every detail in the database. The most critical log information you can read and actions that you can take to make logs from Mongo useful:

  1. The general health of the database, factoring the uptime, and a time-wise availability for each of the database counters.
  2. In the case of containerized and orchestrated applications, the server and database sharing performance statistics are deciphered from inspecting the performance of the daemon and cluster components.
  3. Server performance logs can give a statistical overview of the time taken to execute a query based on a collection or the database in its entirety.
  4. Set log verbosity levels or view logs in a command-line interface for elaborate analysis.
  5. Gauging loads limits and setting thresholds based on currently available infrastructure.

Mongo offers a free log monitoring service named Mongo Atlas, which aggregates Mongo logs and provides insightful metrics. This is exclusive to Mongo logs only and not applicable to the whole stack.

observIQ Solution

We have a more streamlined and cohesive approach to MEAN stack application in the works. This solution brings unparalleled visibility into your logs and gives you much-needed relief from numerous configurations and preset alterations to aggregate your logs into a unified interface. Follow our blogs to get updates related to this.

Deepa Ramachandra
Deepa Ramachandra

Related posts

All posts

Get our latest content
in your inbox every week

By subscribing to our Newsletter, you agreed to our Privacy Notice

Community Engagement

Join the Community

Become a part of our thriving community, where you can connect with like-minded individuals, collaborate on projects, and grow together.

Ready to Get Started

Deploy in under 20 minutes with our one line installation script and start configuring your pipelines.

Try it now