It's all about the answers!

Ask a question

Jazz logging/tracing question


Hung Lam (2911915) | asked Jun 25 '08, 11:08 p.m.
JAZZ DEVELOPER
Hello,
I have some extensions and want to use the same logging/tracing APIs
that Jazz uses in Client/Server/Build components. I found out that Jazz
uses log4j throughout Client/Server/Build components. Example code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there any
guideline on what logging/tracing APIs that Jazz extensions should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

6 answers



permanent link
Richard Backhouse (6661) | answered Jun 26 '08, 8:23 a.m.
JAZZ DEVELOPER
I would recommend using the commons logging api instead of log4j. It
will allows other logging implementations to be supported in the future.

We typically get loggers based on the class. For example :

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

private static Log logger = LogFactory.getLog(ProvisionService.class);

Richard
Jazz Web UI and Server Development.

hvlam wrote:
Hello,
I have some extensions and want to use the same logging/tracing APIs
that Jazz uses in Client/Server/Build components. I found out that Jazz
uses log4j throughout Client/Server/Build components. Example code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there any
guideline on what logging/tracing APIs that Jazz extensions should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

permanent link
Hung Lam (2911915) | answered Jun 26 '08, 11:13 a.m.
JAZZ DEVELOPER
Hi Richard,
Thank you for your prompt reply. I thought LogFactory and Log classes
belong to log4j. Maybe I was wrong. So the example you showed below is
the one that you would recommend us to use. Again, thank you.

Richard Backhouse wrote:
I would recommend using the commons logging api instead of log4j. It
will allows other logging implementations to be supported in the future.

We typically get loggers based on the class. For example :

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

private static Log logger = LogFactory.getLog(ProvisionService.class);

Richard
Jazz Web UI and Server Development.

hvlam wrote:
Hello,
I have some extensions and want to use the same logging/tracing APIs
that Jazz uses in Client/Server/Build components. I found out that
Jazz uses log4j throughout Client/Server/Build components. Example
code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there any
guideline on what logging/tracing APIs that Jazz extensions should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

permanent link
Richard Backhouse (6661) | answered Jun 26 '08, 11:37 a.m.
JAZZ DEVELOPER
The log class names and some of the method names are very similar
between commons logging and log4j.

Richard
Jazz Web UI and Server Development

hvlam wrote:
Hi Richard,
Thank you for your prompt reply. I thought LogFactory and Log classes
belong to log4j. Maybe I was wrong. So the example you showed below is
the one that you would recommend us to use. Again, thank you.

Richard Backhouse wrote:
I would recommend using the commons logging api instead of log4j. It
will allows other logging implementations to be supported in the future.

We typically get loggers based on the class. For example :

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

private static Log logger = LogFactory.getLog(ProvisionService.class);

Richard
Jazz Web UI and Server Development.

hvlam wrote:
Hello,
I have some extensions and want to use the same logging/tracing APIs
that Jazz uses in Client/Server/Build components. I found out that
Jazz uses log4j throughout Client/Server/Build components. Example
code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there
any guideline on what logging/tracing APIs that Jazz extensions
should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

permanent link
Hung Lam (2911915) | answered Jul 01 '08, 4:25 p.m.
JAZZ DEVELOPER
If I use the following logging APIs :

log.info(...)
log.warn(...)
log.error(...)
log.debug(...)
log.trace(...)

in my build or server extension code. Where would these go? I don't
see the .log file in the workspace/.metadata directory under the
buildengine and server. Thank you.


Richard Backhouse wrote:
The log class names and some of the method names are very similar
between commons logging and log4j.

Richard
Jazz Web UI and Server Development

hvlam wrote:
Hi Richard,
Thank you for your prompt reply. I thought LogFactory and Log classes
belong to log4j. Maybe I was wrong. So the example you showed below
is the one that you would recommend us to use. Again, thank you.

Richard Backhouse wrote:
I would recommend using the commons logging api instead of log4j. It
will allows other logging implementations to be supported in the future.

We typically get loggers based on the class. For example :

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

private static Log logger = LogFactory.getLog(ProvisionService.class);

Richard
Jazz Web UI and Server Development.

hvlam wrote:
Hello,
I have some extensions and want to use the same logging/tracing APIs
that Jazz uses in Client/Server/Build components. I found out that
Jazz uses log4j throughout Client/Server/Build components. Example
code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there
any guideline on what logging/tracing APIs that Jazz extensions
should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

permanent link
Richard Backhouse (6661) | answered Jul 04 '08, 2:04 p.m.
JAZZ DEVELOPER
Where and what you see in the log will depend on how you are configuring
the log implementation.

Assuming that your launch references the "org.apache.commons.logging"
and "org.apache.log4j" bundles provided with Jazz the log can be
configured by specifying a path to a log4j.properties file via a System
property. In your launch vm arguments you can add a

-Dlog4j.configuration=file:///${workspace_loc}/<path>

The log4j.properties will dictate the level of logging and where the
logging is sent to. For example in log4j.properties

log4j.rootLogger=WARN, stdout, file

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
%-50.50c - %m%n

log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=jazz.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p
%-50.50c - %m%n

Will set the default log level to WARN and will send the log messages to
both stdout and a file called jazz.log (found where the process is
actually launched from).

You can find out more information for log4j configuration on the Apache
website.

Richard
Jazz Web UI and Server development


hvlam wrote:
If I use the following logging APIs :

log.info(...)
log.warn(...)
log.error(...)
log.debug(...)
log.trace(...)

in my build or server extension code. Where would these go? I don't
see the .log file in the workspace/.metadata directory under the
buildengine and server. Thank you.


Richard Backhouse wrote:
The log class names and some of the method names are very similar
between commons logging and log4j.

Richard
Jazz Web UI and Server Development

hvlam wrote:
Hi Richard,
Thank you for your prompt reply. I thought LogFactory and Log
classes belong to log4j. Maybe I was wrong. So the example you
showed below is the one that you would recommend us to use. Again,
thank you.

Richard Backhouse wrote:
I would recommend using the commons logging api instead of log4j. It
will allows other logging implementations to be supported in the
future.

We typically get loggers based on the class. For example :

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

private static Log logger = LogFactory.getLog(ProvisionService.class);

Richard
Jazz Web UI and Server Development.

hvlam wrote:
Hello,
I have some extensions and want to use the same logging/tracing
APIs that Jazz uses in Client/Server/Build components. I found out
that Jazz uses log4j throughout Client/Server/Build components.
Example code is:

Log log = LogFactory.getLog(componentId);

I just want to confirm that my understanding is correct. Is there
any guideline on what logging/tracing APIs that Jazz extensions
should use?

Is the "componentId" the feature/plugin ID or the service ID?

Thank you.

permanent link
Michele Pegoraro (1.8k14119103) | answered Nov 23 '11, 4:59 a.m.
Hi, regarding to logs I've find that plain APIs provide also an RTC own class:
com.ibm.team.repository.common.LogFactory

I've seen that it has to be used only after TeamPlatform.startup() method.
Which benefit are provided by using this class instead of apache standard class?

Thanks,
Michele.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.