Search This Blog

Friday 24 August 2007

OC4J 10.1.3 j2ee-logging.xml console handler example

A note for myself , as I was trying to find an example on this:

j2ee-loging.xml

<log_handler
name='console-handler'
class='java.util.logging.ConsoleHandler'
formatter='oracle.core.ojdl.logging.SimpleFormatter'
level='FINEST' />

....

<logger name="simplelogging" level="FINEST" useparenthandlers="false">
<handler name="console-handler">
</logger>


Java Code

....
public class LoggingTest extends HttpServlet
{
private static Logger logger =
Logger.getLogger("simplelogging");
....

Date d = new Date();
String s = d.toString();
logger.fine("pas simple logging test the current time is " + s);
// log levels
logger.log(Level.SEVERE,"pas simple logging test SEVERE!");
logger.log(Level.WARNING,"pas simple logging test WARNING!");
logger.log(Level.INFO,"pas simple logging test INFO!");
logger.log(Level.CONFIG,"pas simple logging test CONFIG!");
logger.log(Level.FINE,"pas simple logging test FINE!");
logger.log(Level.FINER,"pas simple logging test FINER!");
logger.log(Level.FINEST,"pas simple logging test FINEST!");

....

Output Location

The output using a console handler will go to the opmn log file for the container being used.

Eg:

$ORACLE_HOME/opmn/logs/<container-log-file>

1 comment:

Buttso said...

Pasmanus, coincidentally I've written up a few examples of using Java logging and Log4J with OC4J recently and discuss how to direct the output into the Oracle Java Diagnostics Logging (OJDL) service we have, and then viewing the log entries using the LogView in ASC.

http://buttso.blogspot.com/2007/09/directing-log-messages-into-oc4j.html
http://buttso.blogspot.com/2007/09/directing-log4j-logs-into-oc4j-logging.html
http://buttso.blogspot.com/2007/09/using-shared-libraries-to-configure.html