Using log4j insert log info into ElasticSearch
Switch branches/tags
Nothing to show
Clone or download
tk1cntt Merge pull request #2 from mudlo/master
timestamps for kibana, log4j mdc support
Latest commit 87e5b24 Oct 31, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src timestamps for kibana, mdc support Mar 29, 2016
.gitignore Log4j for Elastic Search Dec 1, 2012
README.md Upgrade Elasticsearch using rest api Sep 12, 2013
log4j.properties Log4j for Elastic Search Dec 1, 2012
pom.xml Upgrade Elasticsearch using rest api Sep 12, 2013

README.md

log4j-elasticsearch-java-api

Using log4j insert log info into ElasticSearch.

Build the lib


mvn package

Copy log4j-elasticsearch.jar and all lib depend in target/lib to using.

The configuration is simple Properties Configuration


# RootLogger
log4j.rootLogger=INFO,stdout,elastic

# Logging Threshold
log4j.threshhold=ALL

#
# stdout
# Add *stdout* to rootlogger above if you want to use this 
#
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n

# ElasticSearch log4j appender for application
log4j.appender.elastic=com.letfy.log4j.appenders.ElasticSearchClientAppender

The configuration is advance Properties Configuration


....

# ElasticSearch log4j appender for application
log4j.appender.elastic=com.letfy.log4j.appenders.ElasticSearchClientAppender
log4j.appender.elastic.elasticHost=http://localhost:9200
log4j.appender.elastic.hostName=my_laptop
log4j.appender.elastic.applicationName=demo
log4j.appender.elastic.elasticIndex=logging-index
log4j.appender.elastic.elasticType=logging