Git Product home page Git Product logo

jla_05's Introduction

Log4j RELP Plugin

Build Status

Creates Log4j appender that uses RELP to ensure no events are lost.

See log4j.example.properties for example config

Please note

Please note that regarding log4j version 1.2.17 following vulnerabilities exist and we recommend not to use these features:

  • CVE-2020-9488 Improper validation of certificate with host mismatch in Apache Log4j SMTP appender.

  • CVE-2019-17571 Included in Log4j 1.2 is a SocketServer class that is vulnerable to deserialization of untrusted data which can be exploited to remotely execute arbitrary code when combined with a deserialization gadget when listening to untrusted network traffic for log data.

Property explanations

Property Description

log4j.appender.RELPAPPENDER.relpAddress

Connection destination address

log4j.appender.RELPAPPENDER.relpPort

Connection destination port

log4j.appender.RELPAPPENDER.appName

Stream application identifier. Maximum length of 48 characters, limited by RFC5424

log4j.appender.RELPAPPENDER.hostname

Stream host identifier. Maximum length of 255 characters, limited by RFC5424

log4j.appender.RELPAPPENDER.connectionTimeout

Time to wait before timing out connection

log4j.appender.RELPAPPENDER.writeTimeout

Time to wait for destination to accept data

log4j.appender.RELPAPPENDER.readTimeout

Time to wait for destination to acknowledge sent data (low values cause duplicates)

log4j.appender.RELPAPPENDER.reconnectInterval

Time to wait between re-connection attempts

log4j.appender.RELPAPPENDER.useSD

Enables structured data containing uuid and source information

Usage

Pass log4j.properties file as property

-Dlog4j.configuration=file:/path/to/log4j.properties

Using the logger

static Logger logger = Logger.getLogger(MyClass.class.getName());
logger.info("Info Message");
logger.warn("Warning message");
logger.trace("Trace message");
// Finally shutdown so RELP can disconnect gracefully
LogManager.shutdown();

Maven dependency definition

<dependency>
    <groupId>com.teragrep</groupId>
    <artifactId>jla_05</artifactId>
    <version>%VERSION%</version>
</dependency>

Configuring pre-built log4j application

First download wanted versions of jla_05, rlp_01 and rlo_14 from the following urls:

Then run java while pointing classpath to the directory where you downloaded the jars to like:

java -cp "path/to/downloaded/jars/*:target/example.jar" com.teragrep.example.Main

Contributing

You can involve yourself with our project by opening an issue or submitting a pull request.

Contribution requirements:

  1. 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.

  2. Security checks must pass

  3. Pull requests must align with the principles and values of extreme programming.

  4. Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).

Read more in our Contributing Guideline.

Contributor License Agreement

Contributors must sign 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.

jla_05's People

Contributors

kortemik avatar ronja-ui avatar strongestnumber9 avatar

Watchers

 avatar  avatar  avatar  avatar

jla_05's Issues

appenders must inject exception stacktraces if the layout ignores them

Using following kind of EnhancedPatternLayout will skip exception stacktraces

<layout class="org.apache.log4j.EnhancedPatternLayout">
  <param name="ConversionPattern" value="%d{​​​​​​​​​​​​yyyy-MM-dd HH🇲🇲ss.SSS}​​​​​​​​​​​​​​​​​​​ %-5p [%t][%c{​​​​​​​​​​​​​​​​​​​1}​​​​​​​​​​​​​​​​​​​:%L] %m%n" />
</layout>

Using XMLLayout includes them, propably handled there.

<layout class="org.apache.log4j.xml.XMLLayout">
  <param name="LocationInfo" value="true" />
</layout>

Changing EnhancedPatternLayout to use pattern that includes them successfully shows exception stacktraces too:

<layout class="org.apache.log4j.EnhancedPatternLayout">
  <param name="ConversionPattern" value="%d{​​​​​​​​​​​​​​​​​​​yyyy-MM-dd HH:mm:ss.SSS}​​​​​​​​​​​​​​​​​​​ %-5p [%t][%c{​​​​​​​​​​​​​​​​​​​1}​​​​​​​​​​​​​​​​​​​:%L] %m%n%throwable%n" />
</layout>

Meaning we must change the appender to inject them as with the default appenders:
http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/WriterAppender.java?view=markup#l313

verify reconnection functionality

while used for spark2.4 driver logs we see following:

java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
	at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
	at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
	at sun.nio.ch.IOUtil.write(IOUtil.java:51)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:470)
	at com.teragrep.rlp_01.RelpConnection.sendRelpRequestAsync(RelpConnection.java:388)
	at com.teragrep.rlp_01.RelpConnection.sendBatch(RelpConnection.java:244)
	at com.teragrep.rlp_01.RelpConnection.commit(RelpConnection.java:214)
	at com.teragrep.jla_05.RelpAppender.append(RelpAppender.java:235)
	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
	at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
	at org.apache.log4j.Category.callAppenders(Category.java:206)
	at org.apache.log4j.Category.forcedLog(Category.java:391)
	at org.apache.log4j.Category.log(Category.java:856)
	at org.slf4j.impl.Log4jLoggerAdapter.error(Log4jLoggerAdapter.java:498)
	at org.apache.spark.util.SignalUtils$$anonfun$registerLogger$1$$anonfun$apply$1.apply$mcZ$sp(SignalUtils.scala:43)
	at org.apache.spark.util.SignalUtils$ActionHandler$$anonfun$2.apply(SignalUtils.scala:99)
	at org.apache.spark.util.SignalUtils$ActionHandler$$anonfun$2.apply(SignalUtils.scala:99)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at org.apache.spark.util.SignalUtils$ActionHandler.handle(SignalUtils.scala:99)
	at sun.misc.Signal$1.run(Signal.java:212)
	at java.lang.Thread.run(Thread.java:750)

update rlp_01

update rlp_01 because old version has potential stability bugs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.