The views expressed on this blog are my own and do not necessarily reflect the views of my employer.

How to configure Log4j in JDev 11g

Ever wanted to use log4j in your adf project ? Well though Oracle doesn’t recommends the use of log4j, i say its purely your choice to use it or not.

So how do we configure log4j in adf  ? Pretty simple..just follow these steps

1) Add log4j jars in the project library

2) Create a file log4j.properties in your Application Sources Directory (this folder is seen in jdev – in both ViewController and Model Folder).

For Model project this file has to be present at <path of model project>Model\src.

For ViewController project this file has to be present as <path of model project>ViewController\src

3) Paste the following contents

****************************

# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO,ConsoleOut,F
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} – %m%n
log4j.logger.org.apache.jsp=DEBUG
log4j.appender.F=org.apache.log4j.FileAppender
log4j.appender.F.File=C:/Logs/Logger.log
log4j.appender.F.layout=org.apache.log4j.PatternLayout
log4j.appender.F.layout.ConversionPattern=%d{MM-dd@HH:mm:ss,SSS} %-5p (%13F:%L) %3x – %m%n

#Addon for
com.sun.faces.level=FINE

****************************

You can download the working example from here

 

P.S: A good tutorial about ADF Logger is available here


5 Comments on “How to configure Log4j in JDev 11g”

  1. Imesh says:

    HI, I am trying to use Socket appender with UDP. I get an error in my server side while trying to read the message sent by client program.

    Below is my code.

    ByteArrayInputStream bis = new ByteArrayInputStream(recievedPakets);
    ObjectInputStream obj = new ObjectInputStream(bis);
    LogEvent logEvent = (LogEvent) obj.readObject();
    System.out.println(logEvent.toString());

    Below error is throwing when I run the code.

    ClassNotFoundException Error : java.lang.ClassNotFoundException: org.apache.logging.log4j.core.impl.Log4jLogEvent$LogEventProxy


Leave a comment