Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added logging details
  • Loading branch information
Geremy Cohen committed Jul 30, 2013
1 parent d1021df commit 1d238e6
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,73 @@ $ ant test
$ ant clean build test
```

###Configuring Logging
Pubnub implements swappable logging using SLF4J, which allows you to switch different logging frameworks easily. All the logging calls using SLF4J API will be delegated to the underlying logging framework.

Before you enable logging, you need to create a "debug-build" version of the Pubnub-StandardEdition.jar.

####To create a debug-build

1. Go to Terminal on Mac/Linux or command-line on Windows
2. Change directory to the Java folder where you have cloned the git java repo of pubnub (https://github.com/pubnub/java.git)
3. Type "ant debug-build"
4. The debug version of Pubnub-StandardEdition jar file (e.g Pubnub-StandardEdition-3.x.x.jar) will be created.
5. Add this jar as a reference in your project.

To implement logging using log4j you need to add the following references to the project. Using log4j you can log to console or a file or both.

1. slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API
2. slf4j-log4j jar file (e.g. slf4j-log4j-1.7.5.jar or a latest version) which acts as a bridge between slf4j and log4j
3. log4j jar file (log4j-1.2.17.jar or a latest version), which provides the underlying logging framework
4. Along with these references you need to add the log4j.properties file in the CLASSPATH

For example, in your log4j.properties file, configure it to write the logs to a log file:
```java
# Root logger option
log4j.rootLogger=ALL, FILE

# Direct log messages to a log file
log4j.appender.FILE =org.apache.log4j.FileAppender
log4j.appender.FILE.File=/Users/rajat/Projects/eclipsews/log4jloging.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
```

More info can be found here http://www.tutorialspoint.com/log4j/log4j_configuration.htm


ii) To implement logging using simple slf4j you need to add the following references to the project
- slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API
- slf4j-simple jar file (e.g. slf4j-simple-1.7.5.jar or a latest version) which provides the underlying logging framework
- Along with these references you need to add the simplelogger.properties file in the CLASSPATH

iii) To implement logging using logback-classic you need to add the following references to the project
- slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API
- logback-classic and logback-core jar files which provide the underlying logging framework

iv) To implement logging using java.util.logging you need to add the following references to the project
- slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API
- slf4j-jdk14 jar file which acts as a bridge between slf4j and java
- JVM runtime provides the underlying logging framework

v) To implement logging using commons-logging you need to add the following references to the project
- slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API
- slf4j-jcl jar file which acts as a bridge between slf4j and common-logging
- common-logging.jar file which acts as an abstraction layer
- The underlying logging framework is chosen dynamically by commons-logging

vi) To implement no logging you have two options

Option 1:
- Add the reference of slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API and nothing else.

Option 2:
- Add the reference of slf4j-api jar file (e.g. slf4j-api-1.7.5.jar or a latest version) which is the SLF4J API.
- And add a reference to slf4j-nop jar file (e.g. slf4j-nop-1.7.5.jar or a latest version).


More info on SLF4J can be found at http://stackoverflow.com/questions/8737204/how-slf4j-works-no-log-getting-created

###To run the DemoConsole:
```
$ cd jars
Expand Down

0 comments on commit 1d238e6

Please sign in to comment.