How to log informarion in plugin?
Accepted answer
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.
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
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.