https://github.com/teragrep/jsa_01
Teragrep RELP appender for Log4js
https://github.com/teragrep/jsa_01
javascript log4js log4js-node relp relp-client syslog teragrep
Last synced: 3 months ago
JSON representation
Teragrep RELP appender for Log4js
- Host: GitHub
- URL: https://github.com/teragrep/jsa_01
- Owner: teragrep
- License: apache-2.0
- Created: 2022-08-19T07:55:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T11:59:56.000Z (over 1 year ago)
- Last Synced: 2025-02-18T15:53:10.537Z (3 months ago)
- Topics: javascript, log4js, log4js-node, relp, relp-client, syslog, teragrep
- Language: JavaScript
- Homepage: https://teragrep.com
- Size: 80.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
# javascript appender
Create appender for log4js-node to enable RELP usage from node.js applications.
User Story:
As a developer I would like to use jsa_01 to push log messages over relp to a compatible relp-server with syslog envelope== Specs
Requirements Backlog
[options="header,footer"]
|=======================
|# |Title |User Story |Importance |Status
|1 |Rebind |Rebind of the rlp_02 connection must be done after configureable amount of messages | OPTIONAL |Open
|2 |Syslog |Wrap messages in syslog envelope |Must Have |WIP
|3 |RELP |Use rlp_02 library |Must Have |Done
|4 |Lossless|Retry indefinitely and do not lose messages |Must Have |Open
|5 |Robust|Processing must not hang indefinitely due to techinical issues but rather retry new connection |Must Have |Open
|6 |Source Data |Must include origin data in syslog structure-data within source-metadata | Must Have |WIP
|7 |Originator |Must include hostname within new syslog structured-data (SD) so utilization systems can utilize it |Must Have |Done
|8 |app-name |Syslog app-name must be configureable |Must Have |Done
|9 |hostname|syslog hostname must be configureable |Must Have |Done
|10 |server port|Server ports need to be configureable |Must Have |Done
|11 |Server address |server address needs to be configureable | Must Have |Done
|12 |Expose error SyslogMessage |Erros(expecptions) must not be hidden |Must Have |Open
|13 |Extra libraries |Do not use extra libraries |Must Have |Open
|14 |Variable checking|Check variables provided via configuration to be valid and raise errors if not in initilization |Must Have |Done
|15 |Debug flags|Allow passing debulg flags via configuration |OPTIONAL |Open|=======================
== High-level Architecture
image::https://github.com/teragrep/jsa_01/blob/base-feat/images/JSA_01.png[]
== Implementation
The jsAppender to push log messages over relp to a compatible relp-server with syslog envelope.
Use following components for:
* rlp_02: RELP connection
* rlo_08: Generate the Syslog message
* Java-relp-server-demo: RELP compatible server (tested on)How to implement:
* asynchronus behaviour completely controlled by the Jasmine async works.
+
[source,node]
-----------------
npm install
-----------------* Module usage:
+
The appender uses the rlo_08 for handling formatting log messages and rlp_02 to send the log event message to the RELP Server.
+
[source,javascript]
-----------------
const { SyslogMessage, Facility, SDElement, SDParam, Severity } = require('@teragrep/rlo_08')
const { RelpConnection, RelpBatch } = require('@teragrep/rlp_02')
-----------------* Build
+
[source,java]
-----------------
mvn clean package
-----------------* Optional tips:
+
async waterfall method also possible for run in the node engine (need to adjust the code).== Configuration
* `*_type_*` - `*_jsAppender_*`
* `*_hostname_*` - `*_string_*` (defaults to os.hostname()) - origin of the log messages
* `*_appname_*` - `*_string_*`
* `*_serverAddress_*` - `*_string_*`
* `*_serverPort_*` - `*_integer_*` (defaults to 1601) - Port of the relp server is listening in== Example (default config)
[source,javascript]
-----------------log4js.configure( {
appenders: {jsa: { type: jsAppender, appName: 'teragrep' },
console: { type: 'console' },
},
categories: {
jsa: { appenders: ['jsa'], level: 'error' },
default: { appenders: ['jsa'], level: 'trace' },
},
})
-----------------This configuration will send the log event messages to the RELP Server.
== Contributing
// Change the repository name in the issues link to match with your project's name
You can involve yourself with our project by https://github.com/teragrep/jsa_01/issues/new/choose[opening an issue] or submitting a pull request.
Contribution requirements:
. *All changes must be accompanied by a new or changed test.* If you think testing is not required in your pull request, include a sufficient explanation as why you think so.
. Security checks must pass
. Pull requests must align with the principles and http://www.extremeprogramming.org/values.html[values] of extreme programming.
. Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).
Read more in our https://github.com/teragrep/teragrep/blob/main/contributing.adoc[Contributing Guideline].
=== Contributor License Agreement
Contributors must sign https://github.com/teragrep/teragrep/blob/main/cla.adoc[Teragrep Contributor License Agreement] before a pull request is accepted to organization's repositories.
You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep's repositories.