Code Monkey home page Code Monkey logo

fluentd4log4j's Introduction

fluentd4log4j

Join the chat at https://gitter.im/tuxetuxe/fluentd4log4j A Log4J appender to push log events to a fluentd server.

How to Use

Maven dependency

<dependency>
    <groupId>com.twimba</groupId>
    <artifactId>fluentd4log4j</artifactId>
	<version>1.0</version>
</dependency>

Configuration

property default value Description
mdcKeys "" The MDC keys (comma separated) that should be added to the log structure.
tagPrefix "" The fluentd tag prefix to be used
tag "log" The fluentd tag to be used in all the log messages sent there
host "localhost" The fluentd server host to where to send the log messages.
port 24224 The fluentd server port to where to send the log messages.
timeout 15000 (15s) The timeout (in milliseconds) to connect to the fluentd server
bufferCapacity 1048576 (1Mb) The socket buffer capacity to connect to the fluentd server
useConstantDelayReconnector false Switch from the default Exponential Delay reconnector to a constant delay reconnector

Example

log4j.properties

log4j.rootLogger=info, fluentd
log4j.appender.fluentd=com.twimba.fluentd4log4j.FluentdAppender.java
log4j.appender.fluentd.mdcKeys=user,host,whatever
log4j.appender.fluentd.host=fluentdhost

fluentd configuration

<source>
  type forward
  port 24224
</source>

<match ** >
	type stdout
</match>

License

This is available in the Apache Licence 2.0 http://www.tldrlegal.com/license/apache-license-2.0-(apache-2.0)

fluentd4log4j's People

Contributors

dankocherga avatar gitter-badger avatar tuxetuxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fluentd4log4j's Issues

FluentdAppender does not properly handle MDC

The following code:

for (String mdcKey : mdcKeys.split(","))
{
  Object value = event.getMDC(mdcKey);
  if (value != null)
  {
    data.put(mdcKey, value);
  }
}

can be replaced by

for(Map.Entry<String, Object> entry:((Hashtable<String, Object>)MDC.getContext()).entrySet())
{
    if (entry.getValue() != null)
        data.put(entry.getKey(), entry.getValue());
}

This seems to fix the problem for me, although it may not be efficient.

document how to use with log4j

#Hi All,

Is there any short guide on how to configure support for fluentd4log4j in log4j?

I'm using Solr 6.6 which has support for log4j (shipped with slf4j-log4j12-1.7.7.jar and log4j-1.2.17.jar out of the box) and want to configure it to send the logs directly to fluentd.

Any ideas on how to do it ?

Regards,
Constantin

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.