Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to log informarion in plugin?

Hello,
In my plugin, I want maintain log for some activities. How can I add my comments as a log to logs/ccm.log? Also is it possible to maintain separate log file in separate folder(not in ccm.log)? If yes, how can it be done?

Thanks.

0 votes


Accepted answer

Permanent link
On server side, extending the AbstractService class you have the getLog() method that permits to log.
The configuration of the log are managed by log4j.properties file stored in your application configuration folder (like JAZZ_HOME/server/conf/ccm). You can use this file to manage which level log and for which class and what file use to store. I generally use a separated log file for the extensions.
Avinash Bamane selected this answer as the correct answer

1 vote

Comments

Hello Michele,
Thanks for the reply!!
It really helps a lot. But, I have some doubts.
I have created my own FileAppender as below,
log4j.rootLogger=DEBUG, file, tempinfo

existing RTC appender


log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.File=logs/ccm.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} [%30t] %5p %-50.50c  - %m%n

my appender


log4j.appender.tempinfo=org.apache.log4j.RollingFileAppender
log4j.appender.tempinfo.MaxFileSize=10MB
log4j.appender.tempinfo.MaxBackupIndex=15
log4j.appender.tempinfo.File=logs/temp.log
log4j.appender.tempinfo.layout=org.apache.log4j.PatternLayout
log4j.appender.tempinfo.layout.ConversionPattern=%d{ISO8601} [%30t] %5p %-50.50c  - %m%n

I want to have 2 separate log files. One is ccm.log file which will have all RTC related logs and one temp.log, which will have only my plugin logs. How to achieve this?
Thanks

You have to enable your class to log in the second file:

log4j.logger.yourextensionid=DEBUG,tempinfo

yourextensionid must be the component id you've put on the plugin.xml for the extension service. If you have a single componentId for every extension you just need to put that one otherwise any componentId will be needed (you can also use the initial part of the componentId, for example com.yourorg.yourpackage will log both com.yourorg.yourpackage.extension1 and com.yourorg.yourpackage.extension2). And remove tempinfo from rootLogger otherwise you will have ccm logs inside your file too.
Any other configuration is log4j related so take a look to https://logging.apache.org/log4j/1.2/manual.html

Hello Michele,
Got it !! Yes, my plugins have unique component ids for every extension. Now, I am able to have separate log files. Thanks a lot !!


One other answer

Permanent link
On server side, extending the AbstractService class you have the getLog() method that permits to log.
The configuration of the log are managed by log4j.properties file stored in your application configuration folder (like JAZZ_HOME/server/conf/ccm). You can use this file to manage which level log and for which class and what file use to store. I generally use a separated log file for the extensions.

1 vote

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943

Question asked: Nov 25 '15, 6:58 a.m.

Question was seen: 2,700 times

Last updated: Nov 26 '15, 6:28 a.m.

Confirmation Cancel Confirm