Skip to content

Commit 1198712

Browse files
tinker with logging
1 parent 5c0c7c9 commit 1198712

4 files changed

Lines changed: 83 additions & 2 deletions

File tree

‎pom.xml‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@
55
<dependency>
66
<groupId>com.datomic</groupId>
77
<artifactId>datomic-free</artifactId>
8-
<version>0.8.3595</version>
8+
<version>0.8.3627</version>
9+
<exclusions>
10+
<exclusion>
11+
<groupId>org.slf4j</groupId>
12+
<artifactId>slf4j-log4j12</artifactId>
13+
</exclusion>
14+
<exclusion>
15+
<groupId>org.slf4j</groupId>
16+
<artifactId>slf4j-nop</artifactId>
17+
</exclusion>
18+
</exclusions>
19+
</dependency>
20+
<dependency>
21+
<groupId>ch.qos.logback</groupId>
22+
<artifactId>logback-classic</artifactId>
23+
<version>1.0.1</version>
924
</dependency>
1025
</dependencies>
1126
<version>0.0</version>
@@ -25,7 +40,18 @@
2540
</resources>
2641
</build>
2742
<repositories>
28-
<repository>
43+
<repository>
44+
<id>Datomic</id>
45+
<name>Datomic</name>
46+
<url>http://files.datomic.com/maven</url>
47+
<releases>
48+
<enabled>true</enabled>
49+
</releases>
50+
<snapshots>
51+
<enabled>false</enabled>
52+
</snapshots>
53+
</repository>
54+
<repository>
2955
<id>Sonatype</id>
3056
<name>Sonatype Release</name>
3157
<url>http://oss.sonatype.org/content/repositories/releases</url>

‎src/java/hornet/samples/PingConsumer.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hornet.samples;
22

3+
import datomic.samples.IO;
34
import org.hornetq.api.core.TransportConfiguration;
45
import org.hornetq.api.core.client.ClientConsumer;
56
import org.hornetq.api.core.client.ClientMessage;
@@ -16,9 +17,12 @@
1617
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
1718
import org.hornetq.core.server.HornetQServer;
1819
import org.hornetq.core.server.HornetQServers;
20+
import org.slf4j.LoggerFactory;
21+
import org.slf4j.bridge.SLF4JBridgeHandler;
1922

2023
import java.util.HashMap;
2124
import java.util.Map;
25+
import java.util.logging.LogManager;
2226

2327
public class PingConsumer {
2428
public static Map nettyOpts() {
@@ -33,8 +37,12 @@ public static Map nettyOpts() {
3337
return m;
3438
}
3539
public static void main(String[] args) {
40+
SLF4JBridgeHandler.install();
41+
LogManager.getLogManager().getLogger("").info("Ping Consumer Starting");
42+
3643
try
3744
{
45+
3846
// Step 1. Create the Configuration, and set the properties accordingly
3947
Configuration configuration = new ConfigurationImpl();
4048
configuration.setPersistenceEnabled(false);

‎src/java/hornet/samples/PingProducer.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
1616
import org.hornetq.core.server.HornetQServer;
1717
import org.hornetq.core.server.HornetQServers;
18+
import org.slf4j.bridge.SLF4JBridgeHandler;
1819

1920
import java.util.HashMap;
2021
import java.util.Map;
22+
import java.util.logging.ConsoleHandler;
23+
import java.util.logging.Level;
24+
import java.util.logging.LogManager;
25+
import java.util.logging.Logger;
2126

2227
public class PingProducer {
2328
public static Map nettyOpts() {
@@ -31,6 +36,8 @@ public static Map nettyOpts() {
3136
}
3237

3338
public static void main(final String[] args) throws InterruptedException {
39+
SLF4JBridgeHandler.install();
40+
LogManager.getLogManager().getLogger("").info("Ping Producer Starting");
3441
try
3542
{
3643
// Step 3. As we are not using a JNDI environment we instantiate the objects directly

‎src/resources/logback.xml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<configuration>
2+
3+
<!-- prevent per-message overhead for jul logging calls, e.g. Hornet -->
4+
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
5+
<resetJUL>true</resetJUL>
6+
</contextListener>
7+
8+
<appender name="MAIN" class="ch.qos.logback.core.rolling.RollingFileAppender">
9+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
10+
<fileNamePattern>${DATOMIC_LOG_DIR:-log}/%d{yyyy-MM-dd}.log</fileNamePattern>
11+
<maxHistory>72</maxHistory>
12+
</rollingPolicy>
13+
<prudent>true</prudent> <!-- multi jvm safe, slower -->
14+
<encoder>
15+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-10contextName %logger{36} - %msg%n</pattern>
16+
</encoder>
17+
</appender>
18+
19+
<!-- comment this out to see logging of segment->object cache conversions -->
20+
<logger name="datomic.domain" level="INFO"/>
21+
22+
<!-- comment this out to see detailed logging of storage access -->
23+
<!-- <logger name="datomic.kv-cluster" level="INFO"/> -->
24+
25+
<!-- these namespsaces create a ton of log noise -->
26+
<logger name="httpclient" level="INFO"/>
27+
<logger name="org.apache.commons.httpclient" level="INFO"/>
28+
<logger name="org.apache.http" level="INFO"/>
29+
<logger name="org.jets3t" level="INFO"/>
30+
<logger name="com.amazonaws" level="INFO"/>
31+
<logger name="com.amazonaws.request" level="WARN"/>
32+
<logger name="sun.rmi" level="INFO"/>
33+
<logger name="net.spy.memcached" level="INFO"/>
34+
<logger name="com.couchbase.client" level="INFO"/>
35+
<logger name="org.apache.zookeeper" level="INFO"/>
36+
37+
<root level="debug">
38+
<appender-ref ref="MAIN"/>
39+
</root>
40+
</configuration>

0 commit comments

Comments
 (0)