Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Log4j configuration

231 views
Skip to first unread message

krishna prasad

unread,
Nov 30, 2004, 11:34:19 PM11/30/04
to

Hi,
Does Websphere portal server supports apache log4j ? Please let me know
how to configure the same.

--
krishna prasad
------------------------------------------------------------------------
Posted via http://www.webservertalk.com
------------------------------------------------------------------------
View this thread: http://www.webservertalk.com/message554069.html

Scott A. Roehrig

unread,
Dec 2, 2004, 9:52:37 AM12/2/04
to
WebSphere Portal Server itself uses the WAS logging APIs and exposes several
logging API though the portlets.

Use of log4j within a portlet is possible and would include requiring the
necessary log4j jars in the portlet with the configuration file. Another
alternative might be a WAS shared library.

In general, log4j was designed to be usable from any Java context. WAS
itself does not provide the jars, but
that doesn't prohibit you from doing so.

Scott

"krishna prasad" <krishna.pr...@mail.webservertalk.com> wrote in
message news:krishna.pr...@mail.webservertalk.com...

Jeff Knecht

unread,
Dec 6, 2004, 10:22:44 PM12/6/04
to
The following 4 steps can be followed to use log4j in a portlet:

1. Place commons-logging.jar and log4j.jar in the WEB-INF/lib directory
of the portlet war file.


2. Create a text file named commons-logging.properties in the
WEB-INF/classes directory and set the LogFactory:

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory


3. Create a text file named log4j.properties in the WEB-INF/classes
directory. Just follow the directions provided by the log4j docs. One
thing you can do to make life easy (assuming you're logging to a file)
is to use a built-in WebSphere variable to designate the location of the
file to be the same location as SystemOut.log, etc - like this:

log4j.appender.R.File=${SERVER_LOG_ROOT}/my_portlet.log


4. After the application is installed, ensure the Classloader Mode in
BOTH the enterprise application and the web module to PARENT_LAST. If
you don't do this, the portal logger will take over logging and your
log4j settings will have no effect.

Lee Francis Wilhelmsen

unread,
Dec 9, 2004, 7:07:02 AM12/9/04
to
Jeff Knecht wrote:
> 3. Create a text file named log4j.properties ...
> One
> thing you can do to make life easy (assuming you're logging to a file)
> is to use a built-in WebSphere variable to designate the location of the
> file to be the same location as SystemOut.log, etc - like this:
>
> log4j.appender.R.File=${SERVER_LOG_ROOT}/my_portlet.log

Hi

This seemed like a neat trick so I tried this using the WSAD (5.1.2)
portal test environment, but the log file never appears in the expected
log directory. I also tried to deploy it on the company portal server
with the same result. In both cases it always gets created at the root.

So if my wsad installation is in c:\wsad then the log file gets created
in the c:\ root directory when it should have been
c:\wsad\runtimes\portal_v50\log. Can any one tell me why this is?

The SERVER_LOG_ROOT variable seems to be present in the test server
substitution variables tab unders server settings (WSAD) and points to
${WPS_HOME}/log. The WPS_HOME variable points to the correct setting (I
actually had to change it for my test environment), but still no log
file in the log directory...

I'm running on IBM WebSphere Portal 5.0.2.1. The "usual" WPS log files
(wps_YYYY.MM.DD-HH.MM.SS.log) always get created in the log directory so
that's working as normal. However, I noticed this at the top of a log file:

Installation
--------------------------------------------------------------------------------
Product Directory E:\wsad\runtimes\portal_v50
Version Directory ${product.dir}\version
DTD Directory ${version.dir}\dtd
Log Directory ${version.dir}\log
Backup Directory ${version.dir}\backup
TMP Directory C:\DOCUME~1\LEE~1.DIN\LOCALS~1\Temp

Notice the "Log Directory" value. I tried to use the value
${version.dir}\log in my log4j.properties file, but got exact same
results as before.

Can anyone see what's wrong?

Regards
Lee Francis

Scott A. Roehrig

unread,
Dec 9, 2004, 12:25:46 PM12/9/04
to
The configuration of log4j would be done solely by the log4j configuration
file. It has no knowledge of WAS shortcut paths or the like. You would need
to manually specify the location in the configuration file.

Scott

"Lee Francis Wilhelmsen" <le...@start.no-n-o-s-p-a-m> wrote in message
news:cp9f54$4foi$1...@news.boulder.ibm.com...

Lee Francis Wilhelmsen

unread,
Dec 10, 2004, 2:14:47 AM12/10/04
to
Scott A. Roehrig wrote:
> The configuration of log4j would be done solely by the log4j configuration
> file. It has no knowledge of WAS shortcut paths or the like. You would need
> to manually specify the location in the configuration file.

So what you're saying is that
log4j.appender.R.File=${SERVER_LOG_ROOT}/my_portlet.log
or the like won't work becuase log4j has no knowledge of WAS/WPS
shortcut paths?

Regards
Lee Francis

Scott A. Roehrig

unread,
Dec 10, 2004, 9:40:42 AM12/10/04
to
To my knowledge that is correct. The WAS shortcuts won't be surfaced to the
log4j.configuration file.

"Lee Francis Wilhelmsen" <le...@start.no-n-o-s-p-a-m> wrote in message

news:cpbics$55gc$1...@news.boulder.ibm.com...

0 new messages