All that 's written there is still valid. I would like to add a couple of things. First, you need to create the log4j.properties file in the following path:
C:\...\Model\src\
A copy of the log4j.properties file is given here for your convenience:
# **Set root logger level to DEBUG and its only appender to A.
log4j.rootLogger=DEBUG, A
# ***** A is set to be a ConsoleAppender.
log4j.appender.A=org.apache.log4j.ConsoleAppender
# ***** A uses PatternLayout.
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Secondly, when it comes to EJB model projects, you need to add the following code in italics, in order to avoid the expensive use of System.out.println() in your client classes:
...
import org.apache.log4j.Logger;
public class PlaceOrderClient {
static Logger logger =Logger.getLogger("PlaceOrderClient");
/* instead of Logger logger = Logger.getLogger(this.getClass().getSimpleName());*/
public static void main(String [] args) {
try {
final Context context = getInitialContext();
PlaceOrder placeOrder = (PlaceOrder)context.lookup("ejb3inaction-Model-PlaceOrder#actionbazaar.buslogic.PlaceOrder");
if (logger.isDebugEnabled())
logger.debug("Exercising PlaceOrder EJB...");
// System.out.println("Exercising PlaceOrder EJB...");
The full source code is available on OTN:
http://www.oracle.com/technetwork/indexes/samplecode/jdeveloper-adf-sample-522118.html
and is given without any guarantee of support whatsoever.
Finally, in case you prefer working with Eclipse, the process is quite similar. See for example:
http://snippets.dzone.com/posts/show/3248
If you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html
No comments:
Post a Comment
Note: only a member of this blog may post a comment.