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 » Reloading /var/mqsi/common/wsrr/log4j.properties

Post new topic  Reply to topic Goto page 1, 2  Next
 Reloading /var/mqsi/common/wsrr/log4j.properties « View previous topic :: View next topic » 
Author Message
rromito
PostPosted: Wed Oct 31, 2012 10:22 am    Post subject: Reloading /var/mqsi/common/wsrr/log4j.properties Reply with quote

Newbie

Joined: 31 Oct 2012
Posts: 5

We use log4j in our java compute nodes in our WMB 7 flows. We’ve placed a log4j.properties file under /var/mqsi/common/wsrr to enable a ConsoleAppender, which causes the logging output to go to the stdout file under the execution group directory.

This solution works great, except that we need to bounce the broker whenever we want to change the logging level in the log4j.properties file.

Is there a way to make the broker re-read the /var/mqsi/common/wsrr/log4j.properties file when the file changes?

Thanks.
Back to top
View user's profile Send private message
rromito
PostPosted: Wed Oct 31, 2012 10:39 am    Post subject: /var/mqsi/common/wsrr/log4j.properties Reply with quote

Newbie

Joined: 31 Oct 2012
Posts: 5

It looks like we only need to restart the execution group in order to reload the log4j.properties config. This is better than bouncing the entire broker, but it would still be nice if we didn't have to restart anything.

Any suggestions?
Back to top
View user's profile Send private message
bsiggers
PostPosted: Wed Oct 31, 2012 10:48 am    Post subject: Reply with quote

Acolyte

Joined: 09 Dec 2010
Posts: 53
Location: Vancouver, BC

There are a few ways to do this - it's a relatively common question for log4j - not just for message broker. . Check this out for a few suggestions. It's tomcat specific, but it would give you a few directions that you could follow.

http://stackoverflow.com/questions/2115900/is-it-possible-to-reload-log4j-xml-log4j-properties-file-dynamically-in-tomcat

You could also just reload the properties when the JCN that does the logging gets called. This would be non-optimal, but effective.

Hope this helps - best regards,
Ben Siggers.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Oct 31, 2012 10:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Do you mean the log4j from the IAM3 support pac, or a log4j solution you've constructed yourself?

I'd wonder about doing a reload of the execution group rather than a restart if I answered Java questions.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
rromito
PostPosted: Wed Oct 31, 2012 11:16 am    Post subject: Reply with quote

Newbie

Joined: 31 Oct 2012
Posts: 5

Thanks for the quick responses.

This is neither a custom log4j configuration nor the IAM3 support pac.

We're taking advantage of the built in WMB log4j configuration loader. If you put a log4j.properties file in /var/mqsi/common/wsrr, WMB will automatically configure log4j in each execution group using that log4j.properties file.

We like this approach because it's less code for us to maintain and the technique is provided to us by WMB.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Oct 31, 2012 11:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

rromito wrote:
We're taking advantage of the built in WMB log4j configuration loader. If you put a log4j.properties file in /var/mqsi/common/wsrr, WMB will automatically configure log4j in each execution group using that log4j.properties file.


Got a link for that in the WMBv7 InfoCenter?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
rromito
PostPosted: Wed Oct 31, 2012 12:04 pm    Post subject: Reply with quote

Newbie

Joined: 31 Oct 2012
Posts: 5

I found out about /var/mqsi/common/wsrr on this forum.

http://www.mqseries.net/phpBB2/viewtopic.php?p=303981&sid=e78828cca6c0518a81684fcb047543bf

http://www.mqseries.net/phpBB/viewtopic.php?p=336975&sid=55bd93660d0ab535d25e23ef1b263b6c

http://www.mqseries.net/phpBB/viewtopic.php?p=299385&sid=ed80d9560b316fdc52c254097963a49d

and several more links will come up if you search this forum for log4j.properties
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Oct 31, 2012 12:54 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

rromito wrote:
I found out about /var/mqsi/common/wsrr on this forum.

http://www.mqseries.net/phpBB2/viewtopic.php?p=303981&sid=e78828cca6c0518a81684fcb047543bf

http://www.mqseries.net/phpBB/viewtopic.php?p=336975&sid=55bd93660d0ab535d25e23ef1b263b6c

http://www.mqseries.net/phpBB/viewtopic.php?p=299385&sid=ed80d9560b316fdc52c254097963a49d

and several more links will come up if you search this forum for log4j.properties


This forum is not the IBM supplied documentation, despite the quality of the advice and the most worthy occupations of many who post here.

If you look at the threads you posted, they're talking about the WMB classloader feature, which is not what you described:

rromito wrote:
built in WMB log4j configuration loader


WMB does not have any built in functions to load or configure log4j. You can load the log4j jar in the same way you can load anything with that, but it's still a custom configuration not an IBM supplied function. On that basis you may do with it as you will, and IBM will support the class loading function.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Oct 31, 2012 2:01 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

So this is what you've done.
  1. Deployed code that uses log4j into a JCN in a message flow
  2. put the properties file for log4j in a folder that is loaded by a "higher" classloader
.

In this case, the "higher" classloader is *too* high. The wsrr directory happens to be in the load path of the Broker classloader. Not the shared classloader, not the EGshared classloader. The *broker* classloader. Putting anything in there is the same as putting it into /classes. You're slightly safer in this case because you're putting a properties file in there rather than putting an executable class file in there - but you still run the risk of interfereing with any broker internal stuff that happens to want to use log4j.

Please DO NOT put anything into the wsrr directory other than those files that are required to be put in there when configuring connections to wsrr.

Put the properties file in shared-classes, or in the shared-classes part of a JavaClassloader configurable service. That is still a higher level classloader than your JCN code runs in, so it will still get loaded at EG startup.

You've not mentioned, but it sounds like you are also not deploying any particular version of log4j in a jar file to the runtime, but using the base java logging capabilities included in the Java runtime that ships with broker. If you *are* deploying that, then you should look at putting it into the node classloader portion of a JavaClassloader configurable service rather than in the shared classes portion. Then the shared classes portion is still a higher level classloader.

But none of that gets you any closer to having the file be reloaded when it's changed - you still need to reload the EG.

If you want to reload the properties when it's changed, you need to alter your code to specify a specific file and use the configureandwatch option mentioned. And then you don't have to worry about putting the properties file anywhere where any classloader will pick it up - you put it in a known location and instruct log4j where it is.
Back to top
View user's profile Send private message
rromito
PostPosted: Thu Nov 01, 2012 5:01 am    Post subject: Reply with quote

Newbie

Joined: 31 Oct 2012
Posts: 5

Thanks for the feedback.

mqjeff, I moved the log4j.properties file from wsrr to shared-classes and everything still works.

Yes, I didn't include that we've deployed log4j-1.2.16.jar into shared-classes.

We have an alternate solution where we manually configure log4j in each execution group. We were hoping to find a solution that worked without adding something to every execution group.

We haven't delved into the class loader services yet. It sounds like we need to learn more about them.
Back to top
View user's profile Send private message
nanotech
PostPosted: Thu Mar 28, 2013 6:30 pm    Post subject: Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

Hi All,
We are also using log4j for logging in JCNs and have put the log4j.properties in wsrr directory, but after reading the discussion it seems that we should move the file to "shared-classes" directory.

Having said that, we are facing a rather strange issue lately, we have 6 execution groups with different bars deployed and each bar has its own copy of log4j.jar and other dependent jars....We are noticing that when the log file rolls over to next day some of the execution groups keep writing to the previous days log file, while other execution groups write to current day's file.

Has anyone else faced a similar issue ?

Also, Is there a way to create bar file (we are using mqsicreatebar from ant ) without referring the log4j.jar as dependency from toolkit. As I think creating multiple bar files with the copy of log4j.jar in each bar is a bad design. We were thinking of putting log4j.jar and other dependent jars in "shared-classes" directory, which I believe would work just fine , but if I remove reference of log4j.jar from my project (in toolkit ) then it complains in all JCNs because it is using log4j for logging.

Environment: WMB 7.0.0.4
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 28, 2013 8:25 pm    Post subject: Reply with quote

Grand High Poobah

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

you need to do something like in java.logging which you should have used as a preference, or may be appache commons?

java.logging allows you to change logging level, create handlers etc at runtime. All you would need to achieve this is to have a flow that takes a message with the corresponding commands and execute those in java, in the currently running jvm....

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Fri Mar 29, 2013 4:25 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

nanotech wrote:
Is there a way to create bar file (we are using mqsicreatebar from ant ) without referring the log4j.jar as dependency


Yes. Use EXTERNAL REFERENCE. External references will not include the jar in the build.

The InfoCentre is a wonderful place to learn how to use Message Broker.

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fac30280_.htm

Or, IBM training.

http://www-304.ibm.com/services/learning/content/ites.wss/us/en?pageType=course_description&courseCode=WM664

http://www-304.ibm.com/services/learning/content/ites.wss/us/en?pageType=course_description&courseCode=WM674
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Fri Mar 29, 2013 4:40 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

nanotech wrote:
We are noticing that when the log file rolls over to next day some of the execution groups keep writing to the previous days log file, while other execution groups write to current day's file.

Has anyone else faced a similar issue ?


Yes we have. Given the lack of criticality in our log4j files & our plan to create a new "logger" using java.logging we've not cared that much.

Prevailing thinking is that the JVM in EG is holding open a file handle somewhere & preventing the file from rolling over, as we see it in EGs where the application is using log4j to produce high volumes of output in violation of best practice.

Another reason I don't get excited about fixing it. Ignore my best practice advice, pay the price.....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
nanotech
PostPosted: Fri Mar 29, 2013 7:13 am    Post subject: Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

@lancelotlinc : Thanks for the links.

@Vitor and @fjb_saper: Do you think if we move over to java.util.logging , this will fix the issue. Currently we are using sl4j wrapper with log4j
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Reloading /var/mqsi/common/wsrr/log4j.properties
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.