Is it possible to log smartly in CAF application?
What is not smart is to use log()
method from com.webmethods.caf.faces.bean.BaseFacesBean
, beause it logs as jsf logger, so it shares configuration for logging with other things in jsf - it's not application specific.
It is possible when you modify log4j.init.properties
file in ${MWS_HOME}/server/default/config
folder.
When you publish your CAF application from designer - there is new category created. When you log in as sysadmin
user and you open Logging Configuration link
:
there is new category added (I added cafTestApplication):
In you CAF application Java, you can get Logger as:
private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger("/caftestapplication");
Note: category is in lower case (it was changed by MWS)
All you need to use different log (and not _full_.log
) is to add this (MWS restart needed):
log4j.category./caftestapplication=DEBUG,newLogFile
log4j.appender.newLogFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.newLogFile.DatePattern='.'yyyy-MM-dd
log4j.appender.newLogFile.File=${log4j.logging.dir}/newLogFile.log
log4j.appender.newLogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.newLogFile.layout.ConversionPattern=${log4j.message.pattern}
And now all your logging messages are in new newLogFile.log
which is in same folder as _full_.log
.