In this Blog ,I want to discuss about native Logging Mechanism which allow us to track our instance flow
Have You ever heard of generate log messages inside SOA Suite's logging files (diagnostics.log)
It facilitates to write input payload messages or any status messages to the log files at certain points from the BPEL process
From JDeveloper, with a BPEL flow opened, do this:
Step 1: Insert some imports at the top of the source (first ones inside
process tag):
<bpelx:exec import="java.util.logging.Logger" />
<bpelx:exec import="java.util.logging.Level" />
<bpelx:exec import="oracle.fabric.logging.LogFormatter" />
<bpelx:exec import="java.util.logging.Level" />
<bpelx:exec import="oracle.fabric.logging.LogFormatter" />
Step 2 : Insert a Java Embedding action with the following code:
" Logger logger = Logger.getLogger("oracle.soa.Logger");
LogFormatter.configFormatter(logger);
logger.log(Level.WARNING, "Default log method"); "
LogFormatter.configFormatter(logger);
logger.log(Level.WARNING, "Default log method"); "
That's it, basically. The trick is to configure the logger instance using
SOA Fabric's LogFormatter
To avoid doing these steps every time you need to log something, you can use a
class.
Step 1: Create a new Java Class inside your composite project, with the code below:
package info.deepthi.soa.logging;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.fabric.logging.LogFormatter;
public class MyCustomLog {
private static final Logger logger = Logger.getLogger("oracle.soa.Logger");
static {
LogFormatter.configFormatter(logger);
}
public static final void log(String message) {
logger.log(Level.WARNING, message);
}
}
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.fabric.logging.LogFormatter;
public class MyCustomLog {
private static final Logger logger = Logger.getLogger("oracle.soa.Logger");
static {
LogFormatter.configFormatter(logger);
}
public static final void log(String message) {
logger.log(Level.WARNING, message);
}
}
Step 2: Call the function from your Java Embedding actions:
info.deepthi.soa.logging
.
MyCustomLog.log(
"Logging class method"
);
After building, deploying and running your process, this is what you're going to
see from Enterprise Manager's Log page
In my code has "info.invaders.Logger" instead of
"oracle.soa.Logger" as showed above. If you want to know why,
keep reading this post :-)
There's one detail you may have seen that deserves some explanation: I passed a specific package and class (oracle.soa.Logger) in order to retrieve a logger instance. I did this 'cause this package is configured by default when installing the product, and this releases us of some configuration.
But, if you want to use a specific log level for your messages without messing with anything else, the best way to do so is to define a new package and configure it accordingly. Here's how.
There's one detail you may have seen that deserves some explanation: I passed a specific package and class (oracle.soa.Logger) in order to retrieve a logger instance. I did this 'cause this package is configured by default when installing the product, and this releases us of some configuration.
But, if you want to use a specific log level for your messages without messing with anything else, the best way to do so is to define a new package and configure it accordingly. Here's how.
- Define the package you want to use. I'm going with "info.invaders".
- Locate the file logging.xml of your server and open it.
Inside the domain folder, navigate to
/config/fmwconfig/servers/server_name.
Warning: you have to configure the logging.xml file of each SOA instance (server). Not the most cluster-friendly procedure, but that's the way it is. - Include a XML block like this, specifying your package and the lowest log
level you want:
<handler name="odl-handler"/>
<handler name="wls-domain"/>
<handler name="console-handler"/>
</logger>By deepthiReddy
No comments:
Post a Comment