ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Log4j brokerlog.xml Classpath Issue

Post new topic  Reply to topic
 Log4j brokerlog.xml Classpath Issue « View previous topic :: View next topic » 
Author Message
aslam_kumhar
PostPosted: Fri Jan 16, 2015 1:34 am    Post subject: Log4j brokerlog.xml Classpath Issue Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Jan 16, 2015 4:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Best practice says use java.util.logging instead of log4j
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Fri Jan 16, 2015 5:24 am    Post subject: Re: Log4j brokerlog.xml Classpath Issue Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 16, 2015 6:20 am    Post subject: Reply with quote

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
View user's profile Send private message
aslam_kumhar
PostPosted: Mon Jan 19, 2015 12:17 am    Post subject: Reply with quote

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
View user's profile Send private message
aslam_kumhar
PostPosted: Thu Jan 22, 2015 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message
zpat
PostPosted: Thu Jan 22, 2015 4:59 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
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
View user's profile Send private message
aslam_kumhar
PostPosted: Thu Jan 22, 2015 5:44 am    Post subject: Reply with quote

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
View user's profile Send private message
zpat
PostPosted: Thu Jan 22, 2015 6:07 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
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
View user's profile Send private message
aslam_kumhar
PostPosted: Thu Jan 22, 2015 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Jan 22, 2015 6:48 am    Post subject: Reply with quote

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
View user's profile Send private message
aslam_kumhar
PostPosted: Thu Jan 22, 2015 7:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Log4j brokerlog.xml Classpath Issue
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.