You can send Moleculer logs to any endpoint
Log format:
{
timestamp: 1682190435415, // Date.now()
level: "info", // "fatal", "error", "warn", "info", "debug", "trace"
message: "{}", // JSON.stringify of log args
nodeID: "mol-repl_6428", // Unique node identifier
namespace: "local", // Namespace of nodes to segment your nodes on the same network
service: "repl", // service name
source: "v1.repl", // broker, registry, discovery, transporter, cacher
hostname: "linux",
version: 1, // service version
}
$ npm install @1xtr/moleculer-universal-logger
// ES5 example
const UniversalLogger = require('@1xtr/moleculer-universal-logger')
// ES6+ example
import { UniversalLogger } from '@1xtr/moleculer-universal-logger'
module.exports = {
logger: new UniversalLogger({
// put here your options
url: 'https://log-api.eu.newrelic.com/log/v1?Api-Key=your_key' // newrelic EU
}),
}
const defaultOptions = {
url: process.env.UNIVERSAL_LOGGER_URL,
fetchOptions: {
method: "POST",
headers: {
"Content-Type": "application/json",
},
},
hostname: hostname(),
objectPrinter: null,
interval: 10 * 1000,
excludeModules: [], // broker, registry, discovery, transporter, cacher
}