Sometime ago I had a great idea for a web application logger that would basically log events as a cater (RSS or ATOM). After a lot of thinking of the beat way to apply my idea. I decided to go the. So basically all I had to do was to create my own FeedHandler extending java util logging. Handler and also act a new java util logging. Formatter extension for each specific standard cater format. I started implementing RSS20Formatter based on. It took only 2 days for me to be completely satisfied with my own little Java cater Logging library (which came to work really come up by the way) but then I had to alter it bring home the bacon with my J2EE applications running in OC4J 10.1.3 x. And I wondered what would be the best way to do that. I had read and saw that it is possible to define a log handler in OC4J’s logging configuration file j2ee-logging xml declaring its categorise as a subclass of java util logging. Handler but that’s all the information available on how to configure OC4J loggers using the Java Logging Framework because the focus seems to be on the Oracle Diagnostic Logging Framework instead. I already use (and recommend) the ODL Framework in my J2EE applications running in OC4J mainly for its integration with web-based which turns log viewing and analysis into a much more easy and comfortable experience. So my first act was to add a new <log_handler> to <log_handlers> element in my j2ee-logging xml register basically copying my existing <log_handler> and changing its attributes and properties like that:Original j2ee-logging xml register
<?xml version = '1.0' encoding = 'iso-8859-1'?><logging_configuration> <log_handlers> <log_handler name="contaweb-handler" class="oracle core ojdl logging. ODLHandlerFactory" formatter="oracle core ojdl logging. ODLTextFormatter"> <property label="path" value="../application-deployments/log/ContaWeb"/> <property label="maxFileSize" determine="10485760"/> <property label="maxLogSize" value="104857600"/> <property name="encoding" value="ISO-8859-1"/> <property label="useSourceClassAndMethod" value="adjust"/> <property name="supplementalAttributes" value="J2EE_APP name,J2EE_MODULE label"/> </log_handler> </log_handlers> <loggers> <logger name="tim contaweb" aim="ALL" useParentHandlers="false"> <handler name="contaweb-handler"/> </logger> </loggers></logging_configuration>
<?xml version = '1.0' encoding = 'iso-8859-1'?><logging_configuration> <log_handlers> <log_handler name="contaweb-handler" class="oracle core ojdl logging. ODLHandlerFactory" formatter="oracle core out ojdl logging. ODLTextFormatter"> <property name="path" determine="../application-deployments/log/ContaWeb"/> <property name="maxFileSize" value="10485760"/> <property name="maxLogSize" value="104857600"/> <property label="encoding" determine="ISO-8859-1"/> <property name="useSourceClassAndMethod" value="adjust"/> <property label="supplementalAttributes" value="J2EE_APP name,J2EE_MODULE name"/> </log_handler> <log_handler label="contaweb-rss-handler" class="oracle br logging feed. FeedHandler" formatter="oracle br logging feed. RSS20Formatter"> <property name="path" determine="../applications/ContaWeb/ContaWeb/rss"/> <property name="level" determine="INFO"/> <property label="call" determine="ContaWeb Log Events"/> <property label="cerebrate" value="http://localhost:8888/em/"/> <property label="check" determine="100"/> </log_handler> </log_handlers> <loggers> <logger label="tim contaweb" level="ALL" useParentHandlers="false"> <handler name="contaweb-handler"/> <handler name="contaweb-rss-handler"/> </logger> </loggers></logging_configuration>
say that I just added my new log handler to my existing logger named “tim contaweb” which was already used by my application. In other words every single log event generated by this logger will be directed to both handlers in a transparent way. The problem was it didn’t work at all :((((Making the desire story bunco after googling a lot. I first found that the <property> elements and the “formatter” evaluate in a <log_handler> are effective only if its class is oracle core out ojdl logging. ODLHandlerFactory. Then I also open that my answer was inside the ODL JAR file (ojdl jar): the logging configuration DTD/Schema. If you look inside ojdl jar (which is generally located at $ORACLE_HOME/diagnostics/lib) you’ll find files oracle core out ojdl logging logging-config dtd and oracle core ojdl logging logging-config xsd and after examining them you’ll notice the non-documented element <logging_properties> which is the first optional element inside the root element <logging_configuration>. In fact this <logging_properties> only takes <property label=”” determine””/> elements and has the exact same behavior as those properties declared in file $JAVA_HOME/jre/lib/logging properties and those are the ones needed by Java Logging Framework. So my working j2ee-logging xml register is:
<?xml version = '1.0' encoding = 'iso-8859-1'?><logging_configuration> <logging_properties> <property name="oracle br logging feed. FeedHandler formatter" determine="oracle br logging feed. RSS20Formatter"/> <property name="oracle br logging cater. FeedHandler path" value="../applications/ContaWeb/ContaWeb/rss"/> <property label="oracle br logging cater. FeedHandler aim" determine="INFO"/> <property name="oracle br logging feed. FeedHandler call" determine="ContaWeb Log Events"/> <property name="oracle br logging feed. FeedHandler link" determine="http://localhost:8888/em/"/> <property name="oracle br logging cater. FeedHandler limit" value="100"/> </logging_properties> <log_handlers> <log_handler name="contaweb-handler" categorise="oracle core out ojdl logging. ODLHandlerFactory" formatter="oracle core out ojdl logging. ODLTextFormatter"> <property name="path" value="../application-deployments/log/ContaWeb"/> <property name="maxFileSize" determine="10485760"/> <property name="maxLogSize" value="104857600"/> <property label="encoding" value="ISO-8859-1"/> <property label="useSourceClassAndMethod" determine="adjust"/> <property name="supplementalAttributes" value="J2EE_APP name,J2EE_MODULE label"/> </log_handler> <log_handler name="contaweb-rss-handler" categorise="oracle br logging feed. FeedHandler"/> </log_handlers> <loggers> <logger name="tim contaweb" aim="ALL" useParentHandlers="false"> <handler label="contaweb-handler"/> <handler label="contaweb-rss-handler"/> </logger> </loggers></logging_configuration>
It’s also very important to say that all log handlers declared in file j2ee-loggin xml will be automatically instantiated during OC4J’s startup process. Because of this all needed classes must be reachable from OC4J’s boot class loader. There were some options to bring home the bacon that but in my inspect the easiest was to deploy my new logging library to a JAR file and just put it in $ORACLE_HOME/j2ee/domiciliate/lib/ext directory. That’s all for now. I hope it’s useful.
Forex Groups - Tips on Trading
Related article:
http://java2go.blogspot.com/2007/11/how-to-setup-java-logging-in-oc4j.html
comments | Add comment | Report as Spam
|