Skip to content

Commit e4ef03a

Browse files
committed
Small preparations for the release.
1 parent 5df70c4 commit e4ef03a

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### (2020-10-06) v0.8
2+
3+
- Added Redis [Sentinel](https://redis.io/topics/sentinel) support. (#9)
4+
15
### (2019-07-23) v0.7
26

37
- Remove Guava dependency by copying the `RateLimiter`.

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,21 @@ Below you can find a sample `log4j2.xml` snippet employing `RedisAppender`.
5858
</Configuration>
5959
```
6060

61-
If you have Sentinel cluster please configure RedisAppender like this:
61+
One can make `RedisAppender` work against a
62+
[sentinel](https://redis.io/topics/sentinel) setup using `sentinelNodes` and
63+
`sentinelMaster` parameters:
64+
6265
```xml
6366
<RedisAppender name="REDIS"
6467
key="log4j2-messages"
6568
sentinelNodes="localhost:63791,localhost:63792"
6669
sentinelMaster="mymaster">
6770
...
6871
</RedisAppender>
69-
```
72+
```
73+
74+
Note that `sentinelNodes` and `sentinelMaster` have priority over `host` and
75+
`port` parameters.
7076

7177
`RedisAppender` is configured with the following parameters:
7278

@@ -76,8 +82,8 @@ If you have Sentinel cluster please configure RedisAppender like this:
7682
| `key` | String | | Redis queue key |
7783
| `host` | String | `localhost` | Redis host|
7884
| `port` | int | 6379 | Redis port |
79-
| `sentinelNodes` | String | `localhost:63791,localhost:63792` | Redis sentinel nodes as comma-separated list. If specified, `host` and `port` parameters are ignored. |
80-
| `sentinelMaster` | String | `mymaster` | Redis sentinel master name |
85+
| `sentinelNodes` | String | `null` | Redis sentinel nodes as comma-separated list, e.g., `host1:port1,host2:port2`. If specified, `host` and `port` parameters are ignored. |
86+
| `sentinelMaster` | String | `null` | Redis sentinel master name |
8187
| `password` | String | `null` | Redis password |
8288
| `connectionTimeoutSeconds` | int | 2 | initial connection timeout in seconds |
8389
| `socketTimeoutSeconds` | int | 2 | socket timeout in seconds |
@@ -225,7 +231,7 @@ Contributors
225231

226232
# License
227233

228-
Copyright &copy; 2017-2019 [Volkan Yazıcı](http://vlkan.com/)
234+
Copyright &copy; 2017-2020 [Volkan Yazıcı](http://vlkan.com/)
229235

230236
Licensed under the Apache License, Version 2.0 (the "License");
231237
you may not use this file except in compliance with the License.

appender/src/main/java/com/vlkan/log4j2/redis/appender/RedisAppender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.Serializable;
2626
import java.nio.charset.Charset;
27+
import java.nio.charset.StandardCharsets;
2728
import java.util.Set;
2829
import java.util.stream.Collectors;
2930
import java.util.stream.Stream;
@@ -296,7 +297,7 @@ public static class Builder implements org.apache.logging.log4j.core.util.Builde
296297
private String name;
297298

298299
@PluginBuilderAttribute
299-
private Charset charset = Charset.forName("UTF-8");
300+
private Charset charset = StandardCharsets.UTF_8;
300301

301302
@PluginElement("Layout")
302303
private Layout<? extends Serializable> layout = PatternLayout.newBuilder().withCharset(charset).build();

appender/src/main/java/com/vlkan/log4j2/redis/appender/RedisThrottler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ private ObjectName createJmxBeanName() {
7676
String beanName = config.getJmxBeanName();
7777
if (beanName == null) {
7878
LoggerContext loggerContext = appender.getConfig().getLoggerContext();
79-
if (loggerContext == null)
79+
if (loggerContext == null) {
8080
loggerContext = (LoggerContext) LogManager.getContext(false);
81+
}
8182
beanName = String.format(
8283
"org.apache.logging.log4j2:type=%s,component=Appenders,name=%s,subtype=RedisThrottler",
8384
loggerContext.getName(),

0 commit comments

Comments
 (0)