Skip to content

Commit

Permalink
Upgrade Jedis and Logback version (#22)
Browse files Browse the repository at this point in the history
* Upgrade Jedis and Logback version

* Update README file including release notes about new release
  • Loading branch information
sergioasantiago authored and kmtong committed Jan 1, 2020
1 parent 9f9f4d0 commit d1d45cc
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 28 deletions.
155 changes: 151 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,151 @@
/target
/.project
/.classpath
/.settings

# Created by https://www.gitignore.io/api/java,maven,macos,intellij
# Edit at https://www.gitignore.io/?templates=java,maven,macos,intellij

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
.idea/
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

*.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# End of https://www.gitignore.io/api/java,maven,macos,intellij
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Now in Maven Central Repository:
<dependency>
<groupId>com.cwbase</groupId>
<artifactId>logback-redis-appender</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>
</dependency>
```

Expand All @@ -18,16 +18,16 @@ Now in Maven Central Repository:
## Redis Related (RedisAppender Attributes)

* **key**: (required) Redis Key to append the logs to
* **host**: (optional, default: localhost) Redis Server Host
* **port**: (optional, default: 6379) Redis Server Port
* **timeout**: (optional, default: 2000) Redis connection timeout
* **password**: (optional, default: no password) Redis connection password
* **database**: (optional, default: 0) Redis database number
* **host**: (optional, default: localhost) Redis Server Host
* **port**: (optional, default: 6379) Redis Server Port
* **timeout**: (optional, default: 2000) Redis connection timeout
* **password**: (optional, default: no password) Redis connection password
* **database**: (optional, default: 0) Redis database number

## Event Related (JSONEventLayout Attributes)

* **source**: (optional) Logstash Event [source] value
* **sourceHost**: (optional, default: current hostname) Logstash Event [host] value
* **sourceHost**: (optional, default: current hostname) Logstash Event [host] value
* **sourcePath**: (optional) Logstash Event [path] value
* **tags**: (optional) Comma-separated strings of Logstash [tags]
* **type**: (optional) Logstash Event [type] value
Expand All @@ -36,11 +36,11 @@ Since 1.1.1 these fields support MDC property resolution by @{varname}.

## Logback/Java Specific (JSONEventLayout Attributes)

* **mdc**: (optional, default: false) Set to true if you want to log MDC properties
* **location**: (optional, default: false) Set to true if you want to log the source file
* **mdc**: (optional, default: false) Set to true if you want to log MDC properties
* **location**: (optional, default: false) Set to true if you want to log the source file
* **callerStackIndex**: (optional, default: 0) As location is determined by call stack, if you use some
log wrapper, the location will always be the wrapper instead.
Set it to 1 or higher to specify the particular call stack level
log wrapper, the location will always be the wrapper instead.
Set it to 1 or higher to specify the particular call stack level

# Note
## Custom Layout
Expand All @@ -51,10 +51,10 @@ own JSONEventLayout, see the sample configuration below. (Since version 1.1.5)
## Logging Asynchronously

As this appender would synchronously log to the Redis server, this may cause the logging thread
to be hanged on some error conditions (network timeout or so). One resolution would be using the
[AsyncAppender](http://logback.qos.ch/manual/appenders.html#AsyncAppender) provided by standard
to be hanged on some error conditions (network timeout or so). One resolution would be using the
[AsyncAppender](http://logback.qos.ch/manual/appenders.html#AsyncAppender) provided by standard
logback. Please refer to the below example configurations.
(Thanks GuiSim for pointing this out)
(Thanks GuiSim for pointing this out)

## Default values for MDC properties
MDC properties can be configured with default values by using the `:-` signifier. For example: `@{varname:-foo}` will result in `foo` if the `varname` property is not defined.
Expand Down Expand Up @@ -129,6 +129,10 @@ MDC properties can be configured with default values by using the `:-` signifier

# ChangeLogs

## Version 1.1.6 -> 1.1.5

* Upgrade Jedis version to 3.1.0 and Logback to 1.2.3

## Version 1.1.5 -> 1.1.4

* Ability to set custom Layout (Thanks brynjargles suggestion)
Expand All @@ -152,7 +156,7 @@ MDC properties can be configured with default values by using the `:-` signifier
* https://github.com/elasticsearch/logstash/blob/master/lib/logstash/event.rb

Logstash has re-defined its JSON message format as
[An event is simply a tuple of (timestamp, data).]
[An event is simply a tuple of (timestamp, data).]

{
"@timestamp": "2013-02-09T20:39:26.234Z",
Expand All @@ -164,5 +168,3 @@ This implies that the @-prefixed keys is not longer valid and allows a more flex
The original mapping can be found at oldlogstashjson.rb file.

There is one unmapped field "@source". I will turn that into "source" field anyways.


8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.5.2</version>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<version>1.2.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -80,8 +80,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/cwbase/logback/RedisAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ protected void append(ILoggingEvent event) {
client.rpush(key, json);
} catch (Exception e) {
e.printStackTrace();
pool.returnBrokenResource(client);
client = null;
} finally {
if (client != null) {
pool.returnResource(client);
client.close();
}
}
}
Expand Down

0 comments on commit d1d45cc

Please sign in to comment.