Preferences:ToStringGenerator
StringGenerator [Pro version only]
Since Log4E Pro 1.0 the Jakarta Commons StringGenerator is introduced. The StringGenerator is able to display nearly every datastructure. E.g. logger.debug(new String[]{"foo"}); will print something like [Ljava.lang.String;@b166b5 to the output. With that approach, the values of the array are not readable. Using logger.debug(new ToStringBuilder("", MethodParameterStyle.METHOD_PARAMETER_STYLE).append(new String[]{"foo"}).toString()); will print {foo}.
To use the StringGenerator, one has to install it for him or herself. It is included in the Jakarta Commons Lang Package available at http://jakarta.apache.org/commons/lang/
Download the latest distribution and include the commons-lang.jar in your CLASSPATH.
Log4E provides its own ToStringStyle called METHOD_PARAMETER_STYLE. One can define his or her own ToStringStyle or let create Log4E the predefined MethodParameterStyle in his or her own project. To let create the MethodParameterStyle source code by Log4E, just press the "Create ToStrinStyle class ..." button. This has to be done once for each project.
Options:
- Use StringGenerator
-
If checked the Jakarta Commons StringGenerator is used to print the parameters.
Example generated code:
logger.debug("myMethod(" + new ToStringBuilder("", MethodParameterStyle.METHOD_PARAMETER_STYLE).append("String str", str).toString() + ") - start");
The METHOD_PARAMETER_STYLE will be discussed in the option "ToStringStyle"
-
Default: org.apache.commons.lang.builder.ToStringBuilder
-
Unfortunately the ToStringBuilder throws an NullPointerException if the first constructor parameter is set to null. Thus, you have to set a dummy object which has no effect if using the MethodParameterStyle created by Log4E.
-
Default: de.jayefem.log4e.MethodParameterStyle.METHOD_PARAMETER_STYLE
The MethodParameterStyle has to be created in your project before using it. Use "Create ToStringStyle class ..." to create the source code in your project.
-
Using the button will pop up a dialog from which you can choose in which folder the source code of MethodParameterStyle should be created. By default it will create something like src/de/jayefem/log4e/MethodParameterStyle.java