I was just about to write some debug code by hand in my Java classes when I remembered reading about log4j. I checked out the website and it seemed to do exactly what I needed, only better. I have decided to give it a try.
However, after reading a couple of the tutorials and the online manual I find myself running into some trouble. I'm trying to use a logger with a FileAppender, but when I execute my program no messages are ever written to the text file. I know the method with the logging code is being executed because it appears in a stack trace from an exception that is generated shortly after the logging code. In my logging code I create a Logger, create a Layout, and then create a FileAppender passing a simple layout, the name of a text file, and a boolean value of true. I then associate the FileAppender with the Logger and write two messages. When I open the text file identified in my code it is empty. What step am I missing? (I create a text file with the correct name before executing the logging code.) Thanks in advance for the help. Scott Huey, P.S. - I'm using the latest stable release of log4j, Eclipse 3.2.1 and my operating system is Microsoft Windows. Here is some of my logging code: /* * Set up logging code here. */ Logger myLogger = Logger.getLogger(com.vividsolutions.jump.workbench.ui.LayerViewPanel.class); SimpleLayout layout = new SimpleLayout(); FileAppender appender = null; try { appender = new FileAppender(layout, "debug_log.txt", true); } catch(Exception thisException) { System.err.println(thisException.getMessage()); } myLogger.addAppender(appender); Iterator loopThrough = contentIDs.iterator(); myLogger.info("This is a test."); while(loopThrough.hasNext()) { Object contentID = loopThrough.next(); Class contentIDClass = contentID.getClass(); String className = contentIDClass.getName(); myLogger.fatal("The class we couldn't find a renderer for was: " + className); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]