Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Connectors and logging
Ort618
I need to log how my connector works and in real log my Java classes as well.
How can i setup logger in content.jsp file and Java classes? Do i need to use WorkSite log4j.properties file (where this file is) or
i can use my own (this is better)?
Thank you.
Find more posts tagged with
Comments
peter_choe
if you are using log4j that comes with the worksite mp, it will only read one log4j.properties files.
in one of my application, i have set up a logger using log4j and my own property file for the logger. now my log file will log all the worksite mp logs as well as my own java classes.
if you are not familiar with the log4j, you can see
http://logging.apache.org
. the logging properties file should be in $TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/log/default.properties.
Or worse comes to worse, you can do System.out.println calls and look in the stdout.log in the tomcat logs directory.
i am assuming you are using tomcat as the web application server.
Ort618
Thank you. Yes, i use tomcat and OK with log4j, I was able to setup logging for JSP, it's coming to worksitetemp.log file and i have to use WARN to see my messages.
But i can not setup my Java class to log. My classes are not servlet, they more like beeans, so logger.getRootLogger() seems dosn't work, as soon as there are no one. I was tried to setup system variable to keep there path to my own log4j.properties, tnen use PropertyConfigurator.configure(logProp)
to read one, but logging still not coming for Java classes.
I think i am doing something wrong there, will try more.
Migrateduser
$TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/log/default.properties is used by WOM logging subsystem, these logs will go to
$TOMCAT_HOME/webapps/worksitemp/WEB-INF/logs directory.
WorkSite MP Webapp uses a custom wrapper for log4j, it is called EventLogger.
If your JSP is included in the WSMP web app, what you need to do to enable logging is:
<%
EventLogger logger = EventLogger.getLoggerInstance("myConnector");
logger.debug("does it work?"); // you can replace logger.debug() with logger.error(), logger.warn(). logger.info() etc
%>
Here is a bit technical description on how it works, you do not have to understand all this stuff in order to be able to use above code snippet.
The log4j config file used by WSMP Web App is $TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/logger.xml. In fact $TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/logger.xml is only a template; when logging subsystem is initialized, WebApp creates a runtime config file ($TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/logger-runtime.xml) from the template with logging level and log directory taken from Deployment Manager config file ($TOMCAT_HOME/webapps/worksitemp/WEB-INF/config/config.xml). The runtime file is recreated every time app server is restarted.
Defaul log4j priority for WSMP web app logs is 'warn', you can change it to error/info/debug from Deployment Manager.
-bijoy
Ort618
Thanks a lot for explanaition!
In my case the reason was that there was something wrong with my logger.xml coming with last web component version (4.1, sp1), it wasn't well formatted. I have corrected one than all was fine. In real there are 4 xml files inside WEB-INF/config directory that seems wrong (from XML point of view), but i have deal with just logger.xml.