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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Logger in JLink

BrianKrieger
7-Bedrock

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.

Top Tags