Author |
Message
|
aslam_kumhar |
Posted: Fri Jan 16, 2015 1:34 am Post subject: Log4j brokerlog.xml Classpath Issue |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
Hello Everyone,
We had a requirement to log messages and other information regarding flows since Trace Node does not have much options so we decided to use other logging methods.
I am using IIB 9.0.0.2 on windows 7 as development environment and have configured iam3 support pack for log4j and is using log4j node to log messages in my msg flows. I have read the provided documentation for log4j configuration and did exactly as said but no matter where i put brokerlog.xml file (in mqsi_workpath, shared_classes, mqsi_workpath\xml\external, using MQSI_FILENODES_ROOT_DIRECTORY env variable) along with log4j.dtd the flow does not log messages only if i provide absolute path in log4j node then the logging works. I have also used user trace node with debug level and checked mqsi_workpath\components\<IB9NODE>\console.log for possible reasons regarding failures but could not found one.
I have already searched the forum/web for possible solutions and implemented them but no luck . I was wondering is this the correct way of using brokerlog.xml or am i suppose to use configurable services. I am also considering Log4j or java.util.logging using JCN. Any suggestion?
Thanks in advance. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jan 16, 2015 4:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Best practice says use java.util.logging instead of log4j  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 16, 2015 5:24 am Post subject: Re: Log4j brokerlog.xml Classpath Issue |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
aslam_kumhar wrote: |
I am using IIB 9.0.0.2 on windows 7 as development environment and have configured iam3 support pack for log4j and is using log4j node to log messages in my msg flows. I have read the provided documentation for log4j configuration and did exactly as said but no matter where i put brokerlog.xml file (in mqsi_workpath, shared_classes, mqsi_workpath\xml\external, using MQSI_FILENODES_ROOT_DIRECTORY env variable) along with log4j.dtd the flow does not log messages only if i provide absolute path in log4j node then the logging works. |
We have IAM3 on 9.0.0.2. We created a new directory, added it to the CLASSPATH and put the files in that. Make sure that the id the broker is running as has the permissions at the file level.
xeonix wrote: |
I am also considering Log4j or java.util.logging using JCN. Any suggestion? |
Why use a JCN? Why not just write a logging jar (ideally using java.util.logging) and include that like you include IAM3? You can even access it from a User Defined Node (which is really all the log4j node in IAM3 is). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jan 16, 2015 6:20 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You can also create a java procedure that is called directly from ESQL without requiring a User Defined node or a JCN.
And since java.util.logging is included in base Java, you won't need to modify the classpath in any way, or use a JavaClassloader configurable service. |
|
Back to top |
|
 |
aslam_kumhar |
Posted: Mon Jan 19, 2015 12:17 am Post subject: |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
Thanks everyone for their prompt response:
Quote: |
We have IAM3 on 9.0.0.2. We created a new directory, added it to the CLASSPATH and put the files in that. Make sure that the id the broker is running as has the permissions at the file level. |
I will add the new directory classpath and check again.
Quote: |
You can also create a java procedure that is called directly from ESQL without requiring a User Defined node or a JCN.
And since java.util.logging is included in base Java, you won't need to modify the classpath in any way, or use a JavaClassloader configurable service. |
Thats a very good advice but I dont want to waste a lot of time trying to build message structure but if log4j is not suitable for our requirement then we will definitely go with your approach.
I will let you know all with further developments. Thanks again. |
|
Back to top |
|
 |
aslam_kumhar |
Posted: Thu Jan 22, 2015 4:56 am Post subject: |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
aslam_kumhar wrote: |
Vitor wrote: |
We have IAM3 on 9.0.0.2. We created a new directory, added it to the CLASSPATH and put the files in that. Make sure that the id the broker is running as has the permissions at the file level. |
I will add the new directory classpath and check again.
|
Added new directory with log4j config files to classpath but still no luck.
I used a different approach to load brokerlog.xml file using userdefined configurable services. I created by flow which will only execute once when the broker or execution group is started/restarted. Then using java compute note got the userdefined property and called method com.ibm.broker.IAM3.Log4jNode.Log4jNode.initLog4j('config_file_path') although new log files are created but when the flow reaches JavaCompute Node it just crashes. Here's the code for JavaCompute Node file:
Code: |
import com.ibm.broker.IAM3.Log4jNode;
import com.ibm.broker.config.proxy.BrokerProxy;
import com.ibm.broker.config.proxy.ConfigManagerProxyException;
import com.ibm.broker.config.proxy.ConfigManagerProxyLoggedException;
import com.ibm.broker.config.proxy.ConfigurableService;
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.MbException;
import com.ibm.broker.plugin.MbMessageAssembly;
public class Log4jConfiguration extends MbJavaComputeNode {
@Override
public void evaluate(MbMessageAssembly arg0) throws MbException {
try {
BrokerProxy brokerProxy = BrokerProxy.getLocalInstance();
while (!brokerProxy.hasBeenPopulatedByBroker()) {
Thread.sleep(100);
}
ConfigurableService log4jConfigService = brokerProxy.getConfigurableService("UserDefined", "Log4jConfigService");
Properties props = log4jConfigService.getProperties();
Log4jNode.initLog4j(props.getProperty("log4j_path"));
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyException e) {
e.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
}
}
|
Any advice on that.
Last edited by aslam_kumhar on Thu Jan 22, 2015 5:00 am; edited 1 time in total |
|
Back to top |
|
 |
zpat |
Posted: Thu Jan 22, 2015 4:59 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
MQSI FILENODES ROOT DIRECTORY - only works for file nodes.
You can use the broker wide shared-classes folder for jar files. Or even better use the new(er) execution group specific one.
/var/mqsi/config/<BRKNAME>/<EGNAME>/shared-classes
Put the JAR file in there (this directory is created automatically on IIB when a EG is created, or you can create it by hand).
On HA systems - make the same change on both sides of the cluster. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
aslam_kumhar |
Posted: Thu Jan 22, 2015 5:44 am Post subject: |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
zpat wrote: |
MQSI FILENODES ROOT DIRECTORY - only works for file nodes.
You can use the broker wide shared-classes folder for jar files. Or even better use the new(er) execution group specific one.
/var/mqsi/config/<BRKNAME>/<EGNAME>/shared-classes
Put the JAR file in there (this directory is created automatically on IIB when a EG is created, or you can create it by hand).
On HA systems - make the same change on both sides of the cluster. |
It worked thanks @zpat but it would be better if I can get the path from outside the flow like a service or something.
Anyway thanks everyone for helping. |
|
Back to top |
|
 |
zpat |
Posted: Thu Jan 22, 2015 6:07 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I don't think you follow. You don't need to code the path where the jar file is at all - you let the system find it in the classpath (which is automatic).
Put the jar file in one of the shared-classes folders (like the installation document for the log4j node tells you to do).
If you want to store it in a non-system location, just changed the shared-class folder name (for the EG) into a symlink to that location.
Don't code paths in flows. Don't configure path location info for flows to read unless it is necessary and it's not for this.
If you don't have admin rights - work with someone who does - don't try to make a complicated solution just to avoid dealing with someone else. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
aslam_kumhar |
Posted: Thu Jan 22, 2015 6:21 am Post subject: |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
zpat wrote: |
I don't think you follow. You don't need to code the path where the jar file is at all - you let the system find it in the classpath (which is automatic).
Put the jar file in one of the shared-classes folders (like the installation document for the log4j node tells you to do).
If you want to store it in a non-system location, just changed the shared-class folder name (for the EG) into a symlink to that location.
Don't code paths in flows. Don't configure path location info for flows to read unless it is necessary and it's not for this.
If you don't have admin rights - work with someone who does - don't try to make a complicated solution just to avoid dealing with someone else. |
I didn't coded the path in my flows, i just put the config_files in @MQSI_WORKPATH/config/<broker_name>/<execution_group>/shared-classes and it worked. It will do the job, but just to be clear I just wanted to say that it would be better to use Userdefined Configurable Service to retrieve properties in Transformation Nodes for someone like me who didn't want to use the classpath approach. Thanks for your help. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jan 22, 2015 6:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
aslam_kumhar wrote: |
It will do the job, but just to be clear I just wanted to say that it would be better to use Userdefined Configurable Service to retrieve properties in Transformation Nodes for someone like me who didn't want to use the classpath approach. Thanks for your help. |
I would argue something as generic as your logging framework could legitimately sit in shared classes, but if you don't want to do that then there's a facility to load classes into given flows separate from the use of a class path.
As a side point, what do you think is wrong / unusual / nonstandard about putting Java objects in a classpath? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
aslam_kumhar |
Posted: Thu Jan 22, 2015 7:12 am Post subject: |
|
|
Novice
Joined: 30 Oct 2014 Posts: 22
|
Vitor wrote: |
aslam_kumhar wrote: |
It will do the job, but just to be clear I just wanted to say that it would be better to use Userdefined Configurable Service to retrieve properties in Transformation Nodes for someone like me who didn't want to use the classpath approach. Thanks for your help. |
I would argue something as generic as your logging framework could legitimately sit in shared classes, but if you don't want to do that then there's a facility to load classes into given flows separate from the use of a class path.
As a side point, what do you think is wrong / unusual / nonstandard about putting Java objects in a classpath? |
I have no problem with putting jars in shared-classes. Its just that after trying all classpath folders (just not the specific execution group one which did the job) I was unable to load the config file and as told by IAM3 SupportPack manual to enter absolute path name of the brokerlog.xml config file, I just could not find a way to retrieve that path outside from msgflows like a Userdefined configurable service into Compute Node and then initializing the config file rather than hard-coding the path into Log4j Node or in ESQL.
I am new to integration bus and IIB so may be I am over-complicating a simple solution instead of using the standard way. |
|
Back to top |
|
 |
|