Oracle OC4J J2EE logging is based on the J2SE 1.4 java.util.logging. This is the new standard logging utility that has most of the same features log4j has, althought log4j still has more custom logging handlers compared to JUL logging.
You can add your own JUL (java.util.logging) handler as logging handler in the container component (defined in j2ee-logging.xml), but this doesn't affect any of the sub-component loggings, like JMS, server, RMI etc. j2ee-logging.xml affects on custom logging events used in the applications.
One thing to note here is that in order to use e.g. java.util.logging.FileHandler, you must set the "-Djava.util.logging.config.file" -option in the "java -jar oc4j.jar" call to configure the logging options. Setting the properties in the j2ee-logging.xml doesn't have any effect on the java.util.logging handlers.
So in order to run the OC4J with the wanted logging handler you need to startup the container with following command line:
java -Djava.util.logging.config.file=d:\apps\jdev1012\j2ee\home\properties\logging.properties -jar oc4j.jar
Here is a sample j2ee-logging.xml:
<logging_configuration>
<log_handlers>
<log_handler name="oc4j-handler" class="java.util.logging.FileHandler">
</log_handler>
</log_handlers>
<loggers>
<logger name="oracle" level="ALL" useParentHandlers="false">
<handler name="oc4j-handler"/>
</logger>
</loggers>
</logging_configuration>
Here is a sample logging.properties file:
java.util.logging.FileHandler.level=ALL
# "/" the local pathname separator
# "%t" the system temporary directory
# "%h" the value of the "user.home" system property
# "%g" the generation number to distinguish rotated logs
# "%u" a unique number to resolve conflicts
# "%%" translates to a single percent sign "%"
java.util.logging.FileHandler.pattern=%h/central%u.log
java.util.logging.FileHandler.limit=0
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
oracle.emp.kaukovuo.logger.test.LoggerServlet=ALL
1 comment:
instead of using an external logging.properties file and all those stuff you also could use an logging_properties enlement in the logging_configuration element of j2ee-logging.xml :
<logging_properties>
<property name="org.x4juli.handlers.RollingFileHandler.filename" value="c2ejbologxX.log"/>
</logging_properties>
Unfortuantely the parser is undocumented aas well as the properties of the ODLHandlerFactory. The XSD file for the j2ee-logging.xml file is buried deep in the ojdl.jar file.
For understanding the config file and the available properties you need to somehow reverse-engineer the code in the ojdl.jar. This way you can find out the secret properties for logging as text insead of XML using the OJDL logger.
Greetings,
thomas
Post a Comment