Re: Getting started with log4j...
I'm new to log4j, but had similar problems sporadically. You are configuring log4j programmatically, while I was using a config file. It wasn't finding my config file until I learned that the log4j.xml file needs to be somewhere in the classpath (even if it's just ".") or explicitly referenced via a DOMConfigurator.configure(filename) for log4j.xml, or PropertyConfigurator.configure(filename) for log4j.properties, call. I was getting a cryptic (to me) error message. Hopefully, an expert will chime in with more authoritative help. --Wayne Redefined Horizons wrote: 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting started with log4j...
James, I'll try reading about that. Thanks, Landon On 5/22/07, James Stauffer <[EMAIL PROTECTED]> wrote: I don't see anything wrong but I use automatic XML config so I am not familiar with code config. You may want to try XML config. On 5/22/07, Redefined Horizons <[EMAIL PROTECTED]> wrote: > 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] > > -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting started with log4j...
I don't see anything wrong but I use automatic XML config so I am not familiar with code config. You may want to try XML config. On 5/22/07, Redefined Horizons <[EMAIL PROTECTED]> wrote: 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] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Getting started with log4j...
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]
Fwd: problem in connection between log4j and log4cxx
hello i am using chainsaw to receiv logs from other machines the problems is ; when i try to send logs from a simple application using log4cxx to chainsaw i always get error messages when using a SocketReceiver in chainsaw , i always get this message in the logs Connection lost! :: invalid stream header same problem with XML and Socket receiver but i got other log errors here is the configuration file of chainsaw http://jakarta.apache.org/log4j/"; debug="true"> ** the small proigram using log4cxx #include #include #include "log4cxx/logger.h" #include "log4cxx/basicconfigurator.h" #include "log4cxx/appender.h" #include "log4cxx/fileappender.h" #include "log4cxx/patternlayout.h" #include using namespace log4cxx; using namespace log4cxx::helpers; using namespace std; LoggerPtr logger(Logger::getLogger("Myapp")); int main(int argc, char **argv[]) { LOG4CXX_WARN(logger,""); return EXIT_SUCCESS; } the configuration file of log4cxx log4j.rootLogger=DEBUG, A1 log4j.appender.A1=org.apache.log4j.net.SocketAppender log4j.appender.A1.layout=org.apache.log4j.SimpleLayout log4j.appender.A1.remoteHost=ackbar Thank's
Re: Re[2]: logging from commons.httpclient interferes with application logging
Maybe providing some of the lines that go to your mail appender would help. On 5/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >Ursprüngliche Nachricht >Von: [EMAIL PROTECTED] >Datum: 22.05.2007 14:35 >An: "Log4J Users List", "[EMAIL PROTECTED]"<[EMAIL PROTECTED]> >Betreff: Re: logging from commons.httpclient interferes with application logging > >That looks correct except that I think should be the first >child of > Hi James, thanks for your fast answer, but this only corrected some error messages from HTTPClient (didn't know that the order of entries plays a role). The HTTP output appears further in my logfile. Perhaps I will try to put this question to httpclient mailing list. >On 5/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Hi all, >> I'm using Jakarta Commons HttpClient for simulating test requests to >> my web application. There I have configured log4j for logging at debug >> level. But now the output from HttpClient wastes my logfile. How can I >> configure log4j so that the output from a different package is logged >> to an other file? I'm using XML configuration. Here is my log4j. xml: >> >> >> >> http://jakarta.apache.org/log4j/"; > >> >> >> >> >> >> >> >> >> > > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > /> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Thanks in advance, >> Ralf H. >> >> >> Jetzt neu: Der Routenplaner von Tiscali >> http://www.tiscali.de/trav/routenplaner.html >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > >-- >James Staufferhttp://www.geocities.com/stauffer_james/ >Are you good? Take the test at http://www.livingwaters.com/good/ > Jetzt neu: Der Routenplaner von Tiscali http://www.tiscali.de/trav/routenplaner.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: logging from commons.httpclient interferes with application logging
>Ursprüngliche Nachricht >Von: [EMAIL PROTECTED] >Datum: 22.05.2007 14:35 >An: "Log4J Users List", "[EMAIL PROTECTED]"<[EMAIL PROTECTED]> >Betreff: Re: logging from commons.httpclient interferes with application logging > >That looks correct except that I think should be the first >child of > Hi James, thanks for your fast answer, but this only corrected some error messages from HTTPClient (didn't know that the order of entries plays a role). The HTTP output appears further in my logfile. Perhaps I will try to put this question to httpclient mailing list. >On 5/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Hi all, >> I'm using Jakarta Commons HttpClient for simulating test requests to >> my web application. There I have configured log4j for logging at debug >> level. But now the output from HttpClient wastes my logfile. How can I >> configure log4j so that the output from a different package is logged >> to an other file? I'm using XML configuration. Here is my log4j. xml: >> >> >> >> http://jakarta.apache.org/log4j/"; > >> >> >> >> >> >> >> >> >> > > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > /> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Thanks in advance, >> Ralf H. >> >> >> Jetzt neu: Der Routenplaner von Tiscali >> http://www.tiscali.de/trav/routenplaner.html >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > >-- >James Staufferhttp://www.geocities.com/stauffer_james/ >Are you good? Take the test at http://www.livingwaters.com/good/ > Jetzt neu: Der Routenplaner von Tiscali http://www.tiscali.de/trav/routenplaner.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDBCAppender inserts %d instead of the date in the database
Hi All, I am trying to use the log4j.jdbcplus.jdbcappender to log my messages to an oracle database. I am not getting any errors and data is being inserted into the database except that instead of actual logs %c, %d, %p and the like are being inserted. I have tried to use the jdbc.jdbcappender and that logs the messages correctly in the database. The file below is my properties file. log4j.appender.D=org.apache.log4j.jdbcplus.JDBCAppender log4j.appender.D.url=jdbc:oracle:thin:@dbname:1521:TSSD log4j.appender.D.dbclass=oracle.jdbc.driver.OracleDriver log4j.appender.D.username=user_name log4j.appender.D.password=password log4j.appender.D.sql=INSERT INTO SDR_EXCEPTIONS(CREATED_AT, CLASS_NAME, PRIORITY, MESSAGE) VALUES ('%d{DATE}','%c','%p','%m') log4j.appender.D.layout=org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern=[%t] %m %l##%d{dd.MM.}#%d{HH:mm:ss} log4j.appender.D.layoutPartsDelimiter=# log4j.appender.D.buffer=1 log4j.appender.D.commit=true log4j.appender.D.quoteReplace=true log4j.appender.D.throwableMaxChars=3000 I would appreciate any help Thanks Amin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logging from commons.httpclient interferes with application logging
That looks correct except that I think should be the first child of On 5/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi all, I'm using Jakarta Commons HttpClient for simulating test requests to my web application. There I have configured log4j for logging at debug level. But now the output from HttpClient wastes my logfile. How can I configure log4j so that the output from a different package is logged to an other file? I'm using XML configuration. Here is my log4j.xml: http://jakarta.apache.org/log4j/";> Thanks in advance, Ralf H. Jetzt neu: Der Routenplaner von Tiscali http://www.tiscali.de/trav/routenplaner.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
logging from commons.httpclient interferes with application logging
Hi all, I'm using Jakarta Commons HttpClient for simulating test requests to my web application. There I have configured log4j for logging at debug level. But now the output from HttpClient wastes my logfile. How can I configure log4j so that the output from a different package is logged to an other file? I'm using XML configuration. Here is my log4j.xml: http://jakarta.apache.org/log4j/";> Thanks in advance, Ralf H. Jetzt neu: Der Routenplaner von Tiscali http://www.tiscali.de/trav/routenplaner.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]