cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Logger in JLink

BrianKrieger
10-Marble

Logger in JLink

So, just a query of sorts. What kind of logging does anyone out there use? I know, all of y'all's programs work perfectly the first time out no sweat. I still struggle occasionally...........ha ha. So I used to use an open print stream and I want to move to a more sophisticated/native logger now that we're rewriting stuff for Creo 2. My gut is to use the java util logger as there are no additional jars required. My challenge is the xml format which seems a bit verbose. I like to think that the info would be useful, so I'll just deal with it.

All that said, the idea was to collect what anyone else is using. Thoughts on what y'all use?

Brian Krieger


3 REPLIES 3

Brian -

I wrote my own logging utility years ago; something I probably wouldn't
repeat now. If you're committed to working in Java, I suggest you look
at log4j:

In Reply to Brian Krieger:


Brian,

I use java.util.logging, and when I don't want XML I just create plain text logs using the SimpleFormatter...

.

.

.

FileHandler fh = null;
Formatter formatter = new SimpleFormatter();
// Formatter formatter = new XMLFormatter();

File logsDir = new File( getLogsDirPath() );

if (logsDir.exists() == false) {
logsDir.mkdirs();
}
fh = new FileHandler( getLogFile().getAbsolutePath() );
fh.setFormatter(formatter);
logger.addHandler(fh);
logger.setLevel(Level.ALL);

logger.config("Logging started.");
logger.config("Java Runtime: " + System.getProperty("java.home"));
logger.config("ProE Build Code " + pfcGlobal.GetProEBuildCode ());

.

.

.


-Gary

_______________________
Gary Hoffman


PLM/CAD Application Support and Development

Solar Turbines Inc
9280 Sky Park Court
Mail Zone: SP3H
San Diego, CA 92123-4302

-
858.694.6961 Ph
858.694.6733 Fax


So, just a query of sorts. What kind of logging does anyone out there use? I know, all of y'all's programs work perfectly the first time out no sweat. I still struggle occasionally...........ha ha. So I used to use an open print stream and I want to move to a more sophisticated/native logger now that we're rewriting stuff for Creo 2. My gut is to use the java util logger as there are no additional jars required. My challenge is the xml format which seems a bit verbose. I like to think that the info would be useful, so I'll just deal with it.

All that said, the idea was to collect what anyone else is using. Thoughts on what y'all use?

Brian Krieger


I write my tools in a netbeans rcp so they are plugins and use the netbeans native logger based on log4j.

Announcements


Top Tags