background preloader



Log4j tutorial with Tomcat examples This tutorial explains how to set up log4j with email, files and stdout. It compares XML to properties configuration files, shows how to change LogLevels for a running application. Furthermore, we explain best practices on logging and exception handling. Author:Sebastian Hennebrueder Date: February, 22th, 2007 Used software and frameworks Tomcat 5.5 Log4j 1.2.14 PDF version of the tutorial: Source code You can download the current version of log4j from the project home page. Make sure that you use use md5sum to check that the downloaded file is not hacked. In a linux console you can type the following and compare the number to that from the home page: md5sum There are md5sum tools for windows as well. example Create a Java project. Add the log4j.jar to the build path of the project. Create a class with the following content: to

Java Web Development with Stripes by Mark Eagle 01/24/2007 Stripes is an open source, action-based Java web framework designed around the principles that web development should be simple and productive for developers. Traditional Java web development focused on versatility through decoupling, which resulted in multiple configuration files, additional objects, and other fragmented resources. These difficulties subjected many developers to a higher learning curve and reduced productivity. Figure 1 shows the normal flow of events and components that are typical for applications that are written with Stripes. Figure 1. As you can see, this is pretty much what you would expect from an MVC framework. Building Your First Stripe Action Let's jump right into the Stripes framework by creating a "Hello World" example to understand how things fit together. The controller class resembles a POJO (Plain Old Java Object) that implements a Stripes-specific interface called ActionBean. Person First Name is a required field.

Grails Logging Configuring logging in Grails is not as simple one would think. Grails uses Log4J as its logging framework. Log4J configuration is stored in the file. In Grails, this file is generated from Config.groovy source file. The official Grails Logging documentation says that if you want to have a different logging levels for let's say a specific controller, all controllers and the rest of your application, you should define the logging levels as: grails.' Yes, those ticks are required, otherwise you get an error message (No such property: context for class: java.lang.String). So that is what the official documentation and few blogs say. Grails allows you to configure your production, development and testing environments differently if required. But there is a solution to this problem after all. environments { development { ... log4j { appender.stdout = ... rootLogger="error,logfile,stdout" logger { grails { app { controller="debug" } } } } } production { ... }} This works.

JUNG - Java Universal Network/Graph Framework Mockito (Mockito API) java.lang.Object org.mockito.Matchers org.mockito.Mockito Direct Known Subclasses: BDDMockito public class Mockitoextends Matchers Mockito library enables mocks creation, verification and stubbing. This javadoc content is also available on the web page. 1. Following examples mock a List, because everyone knows its interface (methods like add(), get(), clear() will be used). 1. //Let's import Mockito statically so that the code looks clearer import static org.mockito.Mockito.*; //mock creation List mockedList = mock(List.class); //using mock object mockedList.add("one"); mockedList.clear(); //verification verify(mockedList).add("one"); verify(mockedList).clear(); Once created, mock will remember all interactions. 2. By default, for all methods that return value, mock returns null, an empty collection or appropriate primitive/primitive wrapper value (e.g: 0, false, ... for int/Integer, boolean/Boolean, ...). 3. Argument matchers allow flexible verification or stubbing. 4.

Logging facade that allows various implementations to be used like log4j, java logging, commons logging. The chap that made this library has his own logging framework that is supported( by superunknown Apr 10