wood burning stoves 2.0*
The moose likes Websphere and the fly likes RAD6/WAS6 Logging config.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "RAD6/WAS6 Logging config.." Watch "RAD6/WAS6 Logging config.." New topic
Author

RAD6/WAS6 Logging config..

Alan Wanwierd
Ranch Hand

Joined: Jun 30, 2004
Posts: 624
I'm trying to get java.util.Logging working and seem to be struggling. throughout my code I have blocks like this:


and this seems to work - almost... the problem is the log files in question get put by default into this directory:
C:\Program Files\IBM\Rational\SDP\6.0\runtimes\base_v6\profiles\default
When I'd prefer them to be somewhere else! In my deployed environments we have several servers on each node - so writing the logs out at eth node level like this is not so smart!.. I really need more control over where the files end up

Also the format is XML when I would much prefer a SimpleFormatter to be applied. - this should be easy right?

So I found the logging.properties file in:
C:\Program Files\IBM\Rational\SDP\6.0\runtimes\base_v6\java\jre\lib

and it looks like the one below. Either this is not the correct file (there are several on my local machine but I thought this must be the one) - OR I've set it up all wrong.

Can someone point me in the right direction?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I haven't ever used that package, but it does seem to me that this:would provide a relative path name to the logger, and that would cause it to put the logs in your current working directory. Try providing an absolute path name there and see what happens.
Alan Wanwierd
Ranch Hand

Joined: Jun 30, 2004
Posts: 624
The whole point is I dont WANT an absolute path name. There no point in having the logging if I have to change 20,000 lines of code to reflect a filepath ewvery time I want to deploy to a different environment!

I want the directory to be picked out of the logging.properties file so that locally logs can go to:

C:/Documents and Settings/awallace/My Documents/JavaUtilLogs/Invoice.log

and deployed to our Linux servers I can configure a server to log to:

/opt/Websphere/Appserver/profiles/MyNode/logs/ClientAServer/Invoice.log

Problem seems to be that my properties are ignored!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, I'm sorry. If you use a relative path it's relative to your current working directory. That's a rule of all the operating systems you're using. So if you don't like what's happening -- and you don't -- then you have to work out how to provide the absolute path that you want.
Alan Wanwierd
Ranch Hand

Joined: Jun 30, 2004
Posts: 624
then you have to work out how to provide the absolute path that you want
.

Yes indeed - thanks ..... and that, I believe is what the "java.util.logging.FileHandler.directory" property is supposed to do..

BUT.. it cant do it if my logging stuff doesnt pick up that property file...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

But it tells you in that property file itself how to point at it:
# You can use a different file by specifying a filename
# with the java.util.logging.config.file system property.
# For example java -Djava.util.logging.config.file=myfile
You can configure your Websphere server to specify Java system properties; I haven't done that in WAS6 but it's buried several obscure layers deep in WAS5. But the option is there somewhere.
Alan Wanwierd
Ranch Hand

Joined: Jun 30, 2004
Posts: 624


and neither have I and I'm farily clueless as to where exactly I specify this!.. I have also read in my various trawling of the web other poeple have attempted this and found that the properties file is STILL ignored. (Although I'd still give it a go if I was confident that I was putting the reference in the right place)

So if theres anyone out there who can offer me some constructive advice I'd really appreciate it! (Not that I dont appreciate Pauls thoughts)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No, actually I had done it in WAS6. Here's how you set JVM system properties in the admin console:

Servers > Application servers > server1 (or your server) > Java and Process Management > Process Definition > Java Virtual Machine > Custom Properties

There, that wasn't that hard to find, was it? (NOT!)

Anyway that's where you put the name and value of that system property. You will have to restart the server for the property to take effect. Good luck!
Alan Wanwierd
Ranch Hand

Joined: Jun 30, 2004
Posts: 624
Ooops...

I attempted that putting in:

Propertyname='java.util.logging.config.file'
PropertyValue='C:\MyPathTo\logging.properties'

but it made no difference asfter teh restart so I tried agaain with:

Propertyname='-Djava.util.logging.config.file'
PropertyValue='C:\MyPathTo\logging.properties'

..and for good measure included it in the "Generic JVM properties" list on the "Servers > Application servers > server1 (or your server) > Java and Process Management > Process Definition > Java Virtual Machine " page..

Now my server doesnt start up and the only thin in ANY log I get is a rather depressing:
The JVM option is invalid: -Xquickstart,
Could not create the Java virtual machine.


So now I have a server that doesnt start and I can get to the console to undo my fiddling about... Perhaps I should've left well alone left the old deprecated RASI logging that we had before our RADWAS6 upgrade?!


---- Added-----
Just hacked the server.xml configuration file to remove some bits and I now have a server starting again! Phew!!!
[ March 06, 2007: Message edited by: Adrian Wallace ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, good luck. I've never heard of anybody trying to use java.util.logging for web applications before, so you might be a pioneer. Perhaps you should experiment with it in a simpler environment first? Most people use log4j in web applications, because of the known defects in Sun's logging package.
Stephanie Waldon
Greenhorn

Joined: Feb 11, 2011
Posts: 1

@Paul - he never said he was attempting to log a web application....

@Alan - I'm sure since you posted this years ago, you found your solution, however, for all of us searching/googling that may have hit on this page... I have some info to help.

First - One of the best articles I've seen written (and I've read a TON) regarding WAS logging is:

http://www.ibm.com/developerworks/websphere/techjournal/0802_supauth/0802_supauth.html

It is a good reference for IBM's recommendations, and for how to integrate JUL into your application.

Second - It is possible to log and configure logging of your application OUTSIDE of Websphere's server logs. Don't give up!

Tips....
1. Referencing the article link above, if you read WAY down towards the bottom, a KEY component to JUL configuration is this:
[quote]WebSphere Application Server initializes the logging environment based on server configuration settings rather than using the JUL logging.properties settings in the JRE/lib directory (which is the JUL default).[/quote]
Therefore overriding the Logger.properties values in the ...{Websphere Installation}/java/jre/lib location, does nothing at all.

2. Since WAS6, JUL has been the preferred logging mechanism for WebSphere, and is integrated with the Websphere Application Server logs. And, those logs will pick up every System.Out for any resource and package your application uses. You can still use Log4J, but IBM will not support or help you with logging via Log4J.

3. Websphere's documentation for your version of Websphere Application Server has pretty good documentation, if you know where to find it. Here is a link to the 6.1 version of the "Adding logging and tracing to your Application", which is a starting point, and then you need to dig deeper.

[quote][i]http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/ttrb_addtrace.html[/i][/quote]

There is a LOT of information pages to go through, which all have benefits to how/why/what things are.

4. The page for how to set up, configure, and MOST importantly WHERE to put the Logger.properties files:
[quote][i]http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rtrb_configjavalogapps.html[/i][/quote]


5. AND, last but not least.... When all else fails, and you cannot get what you want with JUL, and you want to go with Log4J or Commons Logging, here are some good places to find out how:

-- for JCL http://www.ibm.com/developerworks/websphere/techjournal/0901_supauth/0901_supauth.html
-- more JCL http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/ctrb_classload_jcl.html

-- http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14045904

and from that last page (is the key to overriding logging for JCL and Log4j):

[quote]
The META-INF/services approach has been working for us for years on many
different versions of WAS. (We're on 6.1 now) You don't need (or likely
want) to change the classloader ordering policy.

Just make the contents of that file:

org.apache.commons.logging.impl.Log4jFactory

A couple references:

http://www-1.ibm.com/support/docview.wss?uid=swg27010153
[/quote]



Happy Logging!
Douglas Rowe
Greenhorn

Joined: Dec 09, 2003
Posts: 10
Thanks Stephanie, you are a light in a very dark place (WAS). Well done.


Whenever you find yourself on the side of the majority, it is time to pause and reflect. Mark Twain
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RAD6/WAS6 Logging config..
 
Similar Threads
Error in setting SecureRMIClientSocketFactory
java.util.Logging configuration...
NX: which logging file?
JBoss performance decrease
why the logging is not working ?