JavaScript Logging
Windchill now includes a JavaScript logging package, called log4javascript, which is a third-party JavaScript library from log4javascript.
Putting in Logging Statements
While this package is made to work and act just like log4j, there are a few choices about how to do things. Windchill provides loggers for navigation and other components that start with the PTC package name and this is a good practice for developers to follow.
See the full documentation at: http://log4javascript.org/docs/index.html
Here is one simple usage example:
var mylogger = log4javascript.getLogger("PTC.mypackage");
mylogger.trace("...");
mylogger.debug(...);
myLogger.time("timername");
myLogger.timeEnd("timername");
By default, all the messages logged under the PTC top level logger will be pushed to the browser console (Firefox) or shown in a popup browser window (the PopUpAppender for IE). Also, the messages will be logged to the server's log4j file by the Log4JavascriptController’s logger. You are required to change the property value logger.log4javascript.level to INFO in the \codebase\WEB-INF\log4jMethodServer.properties file.
Turning on Logging
Logging may be turned on in one of the following ways:
Add a jsLog URL parameter
To turn on global logging, append jsLog=true to the end of a Windchill URL in the browser’s address field:
http://ah-lisa.ptcnet.ptc.com:1600/Windchill/app/#ptc1/comp/home.overview?
oid=OR%3Awt.org. WTUser%3A21639&u8=1&jsLog=true
This is the same as turning on TRACE level logging on the PTC logger.
Programmatically (in JavaScript code or in the console)
To programmatically turn on logging, include the following:
var mylogger = log4javascript.getLogger("PTC.mypackage");
mylogger.setLevel(log4javascript.Level.TRACE);
Using a UI
Enter the URL address “javascript:PTC.log.startLogger()" to launch a UI that lets you enable logging. Just hit "Ok" to enable all loggers or enter a logger name to enable a specific logger.
From the Tools Page
You can enable jsLog from Customization > Tools > jsLog.
See additional information in the javadoc for the PTC.log object JavaScript.
Log4j
Log4j loggers can be enabled from the UI, accessible from the Tools page. Note that this feature works only for Site Administrators. This and many other site tools are also available under Site > Utilities > Server Status > Monitoring Tools.
Was this helpful?