Skip to content

newrelic-experimental/newrelic-java-log-forwarder

New Relic Open Source experimental project banner.

GitHub forks GitHub stars GitHub watchers

GitHub all releases GitHub release (latest by date) GitHub last commit GitHub Release Date

GitHub issues GitHub issues closed GitHub pull requests GitHub pull requests closed

New Relic Java Log Forwarder

Log Forwarder for AIX, HP-UX, Linux, OSX/MacOS & Solaris/SunOS

This Java log forwarder plugin proves invaluable in scenarios where out-of-the-box New Relic logging solutions are absent for specific platforms, such as AIX, HP-UX, Solaris, OSX/MacOS, and Linux operating systems. It seamlessly integrates into environments running JDK 8 (& above) , providing a straightforward configuration process and effortless execution. Whether encountering unique system configurations or exploring diverse platforms, this plugin stands as a reliable solution for forwarding logs to New Relic, ensuring comprehensive observability across a broad spectrum of systems.

Installation Guide

Step 1: Download and Extract the Release

Download the release and extract the Zip file log-forwarder-plugin-v.x.z.zip.

Step 2: Create a Configuration File config.json

{
  "api_key": "<ingest_key>",
  "application_name": "nrlabs-java-loggerv1.0",
  "log_check_interval_ms": 120000,
  "api_url": "https://log-api.newrelic.com/log/v1",
  "log_files": [
    {
      "name": "mylog-file",
      "file": "/Users/gsidhwani/Documents/GitHub/NR-LOG/newrelic-java-logger/mylog.log",
      "attributes": {
        "logtype": "custom"
      }
    },
    {
      "name": "mynginx-logs",
      "file": "/Users/gsidhwani/Documents/GitHub/NR-LOG/newrelic-java-logger/xyz.log",
      "attributes": {
        "logtype": "nginx"
      }
    }
  ]
}
  • api_key: The API key used for authentication when sending logs to New Relic.
  • application_name: The name of the application or service from which the logs are being collected.
  • log_check_interval_ms: The interval, in milliseconds, at which the log forwarder checks for new log entries to send to New Relic.
  • api_url: The URL of the New Relic log API endpoint where the logs will be sent.
  • log_files: An array of log files to be monitored and forwarded.
  • name: A descriptive name for the log file.
  • file: The absolute path to the log file on the file system.
  • attributes: Additional attributes or metadata associated with the log file, such as the logtype.

These parameters allow you to configure the log forwarder to monitor specific log files, collect log entries at regular intervals, and send them to New Relic for analysis and visualization. Adjust these settings according to your application's requirements and environment.

Step 3: Set Environment Variable LOG_CONFIG

export LOG_CONFIG=config.json  

Step 4: Run the Log Forwarder

java -jar log-forwarder-all.jar

Sample command line output

Logging process started successfully...
Sending 296 log events to New Relic...
Logs sent to New Relic successfully: 2024-05-17T14:18:55.552
Sending 48 log events to New Relic...
Logs sent to New Relic successfully: 2024-05-17T14:22:57.194

Follow these steps to install and configure the log forwarder for your Java application.

Building

./gradlew clean shadowJar

The jar log-forwarder/build/libs/log-forwarder-all.jar will be created.

Logs at New Relic Platform - A Sample

image

Support

New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub.

We encourage you to bring your experiences and questions to the Explorers Hub where our community members collaborate on solutions and new ideas.

Contributing

We encourage your contributions to improve Salesforce Commerce Cloud for New Relic Browser! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

License

New Relic Java Log Forwarder is licensed under the Apache 2.0 License.