diff --git a/README.md b/README.md index a2012c7..4b57e08 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,10 @@ In `web.xml` file: debug false + + logBody + true + MoesifFilter @@ -261,6 +265,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe debug false + + logBody + true + MoesifFilter @@ -324,6 +332,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe debug false + + logBody + true + MoesifFilter @@ -386,6 +398,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe debug false + + logBody + true + MoesifFilter diff --git a/servlet-example/README.md b/servlet-example/README.md index c809536..395762c 100644 --- a/servlet-example/README.md +++ b/servlet-example/README.md @@ -14,6 +14,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe debug false + + logBody + true + MoesifFilter diff --git a/servlet-example/pom.xml b/servlet-example/pom.xml index bf5ddc4..ff56b51 100644 --- a/servlet-example/pom.xml +++ b/servlet-example/pom.xml @@ -28,7 +28,7 @@ com.moesif.api moesifapi - 1.6.0 + 1.6.3 @@ -41,7 +41,7 @@ com.moesif.servlet moesif-servlet - 1.5.2 + 1.5.7 diff --git a/servlet-example/src/main/webapp/WEB-INF/web.xml b/servlet-example/src/main/webapp/WEB-INF/web.xml index e7b8e94..7f3367c 100644 --- a/servlet-example/src/main/webapp/WEB-INF/web.xml +++ b/servlet-example/src/main/webapp/WEB-INF/web.xml @@ -15,6 +15,10 @@ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> debug true + + logBody + true + MoesifFilter diff --git a/spark-servlet-example/README.md b/spark-servlet-example/README.md index c9f6920..148c542 100644 --- a/spark-servlet-example/README.md +++ b/spark-servlet-example/README.md @@ -16,6 +16,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe debug false + + logBody + true + MoesifFilter diff --git a/spark-servlet-example/pom.xml b/spark-servlet-example/pom.xml index c6cf6bc..7b2097b 100644 --- a/spark-servlet-example/pom.xml +++ b/spark-servlet-example/pom.xml @@ -58,12 +58,12 @@ com.moesif.api moesifapi - 1.6.0 + 1.6.3 com.moesif.servlet moesif-servlet - 1.5.2 + 1.5.7 javax.servlet diff --git a/spark-servlet-example/src/main/webapp/WEB-INF/web.xml b/spark-servlet-example/src/main/webapp/WEB-INF/web.xml index 704695b..098eae0 100644 --- a/spark-servlet-example/src/main/webapp/WEB-INF/web.xml +++ b/spark-servlet-example/src/main/webapp/WEB-INF/web.xml @@ -15,6 +15,10 @@ debug true + + logBody + true + SparkFilter diff --git a/spring-example/README.md b/spring-example/README.md new file mode 100644 index 0000000..91245d7 --- /dev/null +++ b/spring-example/README.md @@ -0,0 +1,52 @@ +#### Spring Boot example + +In order to run this example you will need to have Java 7+ and Maven installed. + +Before starting, check that your maven version is 3.0.x or above: + +```sh +mvn -v +``` + +1. Clone the repository + + ```sh + git clone https://github.com/Moesif/moesif-servlet + cd moesif-servlet + ``` + +2. Update MyConfig to use your own Moesif ApplicationId +(Register for an account on [moesif.com](https://www.moesif.com)) + + ```sh + vim spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java + ``` + +3. Compile the example + + ```sh + cd spring-example + mvn clean install + ``` + +4. Run spring-example (from the spring-example dir) + + ```sh + java -jar target/moesif-spring-example.jar + ``` + + Alternatively: + + ```sh + mvn spring-boot:run + ``` + + +5. Go to `http://localhost:8080/greeting` or the port that Spring Boot is running on. + +6. Set logBody flag to `false` in `MyConfig.java` file to remove logging request and response body to Moesif + +```java + // Set flag to log request and response body + moesifFilter.setLogBody(true); +``` diff --git a/spring-example/pom.xml b/spring-example/pom.xml index ac6cde6..13ff788 100644 --- a/spring-example/pom.xml +++ b/spring-example/pom.xml @@ -43,7 +43,7 @@ com.moesif.servlet moesif-servlet - 1.5.2 + 1.5.7 diff --git a/spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java b/spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java index 1442c2d..3046b42 100644 --- a/spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java +++ b/spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java @@ -52,6 +52,11 @@ public String getApiVersion(HttpServletRequest request, HttpServletResponse resp } }; - return new MoesifFilter("Your Application Id", config, true); + MoesifFilter moesifFilter = new MoesifFilter("Your Application Id", config, true); + + // Set flag to log request and response body + moesifFilter.setLogBody(true); + + return moesifFilter; } } diff --git a/spring-mvc-example/README.md b/spring-mvc-example/README.md new file mode 100644 index 0000000..1ab0941 --- /dev/null +++ b/spring-mvc-example/README.md @@ -0,0 +1,65 @@ +#### Spring MVC example + +In order to run this example you will need to have Java 7+ and Maven installed. + +Before starting, check that your maven version is 3.0.x or above: + +```sh +mvn -v +``` + +1. Clone the repository + + ```sh + git clone https://github.com/Moesif/moesif-servlet + cd moesif-servlet + ``` + +2. Update MyConfig to use your own Moesif ApplicationId +(Register for an account on [moesif.com](https://www.moesif.com)) + + ```sh + vim spring-mvc-example/src/main/webapp/WEB-INF/web.xml + ``` + +3. Run spring-mvc-example + + ```sh + cd spring-mvc-example + mvn jetty:run + ``` + +4. Go to `http://localhost:8080/api/json`. In your Moesif Account, you should see event logged and monitored. + +Shut it down manually with Ctrl-C. + +In Spring MVC + XML configuration, you can register the filters via web.xml + +In `web.xml` file: + +```xml + + + MoesifFilter + com.moesif.servlet.MoesifFilter + + application-id + your application id + + + debug + false + + + logBody + true + + + + MoesifFilter + /* + + + +``` +You may have to override `onStartup()` to pass in the MoesifConfiguration object. \ No newline at end of file diff --git a/spring-mvc-example/pom.xml b/spring-mvc-example/pom.xml index 0527804..891c8ab 100644 --- a/spring-mvc-example/pom.xml +++ b/spring-mvc-example/pom.xml @@ -50,7 +50,7 @@ com.moesif.servlet moesif-servlet - 1.5.2 + 1.5.7 diff --git a/spring-mvc-example/src/main/webapp/WEB-INF/web.xml b/spring-mvc-example/src/main/webapp/WEB-INF/web.xml index 4629df8..0ed3aaf 100644 --- a/spring-mvc-example/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-example/src/main/webapp/WEB-INF/web.xml @@ -30,6 +30,10 @@ debug false + + logBody + true +