[FAQ] Forwarding Logs from a Specific Application to Logstash in io.Connect Desktop


Question

How do I forward logs from only one specific application to Logstash or another log collector, without forwarding logs from all applications?

Log4js does not support filtering individual files within a multiFile appender. If you want to add e.g. logstash to the app-own-log category (the category used by the multiFile appender), all application logs in the logs/applications/ directory are forwarded to Logstash, including noisy applications you may not want to ship.


Solution

Create a Dedicated Category for the Specific Application

You can create a separate Log4js category that matches the application name. This category includes both the multiFile appender (so logs still go to the file system) and the logstash appender (so logs are also forwarded to Logstash). All other applications remain in the app-own-log category with file-only logging.

In the logging configuration, add a new category named after the target application:

"categories": {
    "default": {
        "appenders": ["out", "app", "logstash"],
        "level": "info"
    },

    "app-own-log": {
        "appenders": ["applications"],
        "level": "info"
    },

    "mlp-launchpad-toolbar": {
        "appenders": ["applications", "logstash"],
        "level": "info"
    }
}

Inside the application, create a sub-logger with the matching name:

io.logger.subLogger("app1").publishLevel("info");

With this setup, only app1.log will be sent to Logstash, while all other application logs remain on the local file system only.

Creating a sub-logger win’t disable the interception of console messages, unhandled errors, or network request errors. These are captured globally by io.Connect Desktop and still flow into the logger pipeline as before. The interception settings configured in the app definition under "details" > "logging" (such as consoleMessages, networkRequestErrors, and unhandledErrors) remain fully active.