From: Timothy A. <tim...@ca...> - 2010-04-26 14:04:56
|
We do bundle a log4j properties file and jar file in the WAR file, under the WEB-INF/classes and WEB-INF/lib directories respectively. Our application is designed to work with the Apache Tomcat 6.x Servlet Container. I know the classloader is clearly documented <http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html>, but I've never had to consider adjusting it or verifying that it works correctly before. I'm not sure where that leaves me for now. I'll try to dig around and see what I find out, and maybe I'll discover another lead or hear some more ideas. Thanks again for all of your help! Tim Blaine Simpson wrote: > One way I've fixed similar situations before was to ensure that > war-first ClassLoading algorithm is set and honored by your app server, > and then bundle a log4j jar file and the log4j properties in your war > (or exploded web app). That way, all of the classes and resources are > resolved from your web app before looking elsewhere. With everything > relevant being resolved at the same place and at highest priority, > intra-visibility problems are much less likely. > > > On 04/23/2010 10:48 AM, Timothy Astle wrote: > >> Thanks for your reply Blaine. >> >> After doing some more tests, I discovered that the logger sometimes >> finds the appender information. >> >> The appender is setup correctly. We don't use the root logger (except >> sometimes when debugging) because we correctly set up the loggers for >> each dependency. We only have a single log4j.properties file and that >> is in the WEB-INF/classes directory. >> >> We do use Spring Framework in our application. The logger seems to >> work fine for everything else. When our web application starts up, we >> do initialize a org.hsqldb.server.server.Server() object. >> >> I think your suspicions are on the right path. The Server can't find >> or doesn't know about the log4j.properties file... at times. >> >> Do you have any suggestions? >> >> >> Here is a snip of the log4j.properties file: >> >> <snip> >> >> # This is the default logger. Adjust this during development. >> # Comment out this line to check to see if all of the other >> # log to file packages have been set up correctly. >> #log4j.rootLogger=WARN, CONSOLE >> >> # Below loggers ensure all packages are logged to the >> # appropriate files. >> log4j.logger.freemarker=ERROR, DEPENDENCIESLOG >> log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL, >> DEPENDENCIESLOG >> log4j.logger.com.opensymphony.xwork2=ERROR, DEPENDENCIESLOG >> log4j.logger.org.apache.commons=ERROR, DEPENDENCIESLOG >> log4j.logger.org.apache.struts2=ERROR, DEPENDENCIESLOG >> log4j.logger.org.apache.tiles=ERROR, DEPENDENCIESLOG >> log4j.logger.org.displaytag=ERROR, DEPENDENCIESLOG >> log4j.logger.org.hibernate=ERROR, DEPENDENCIESLOG >> log4j.logger.org.hsqldb=ERROR, DEPENDENCIESLOG >> log4j.logger.org.springframework=ERROR, DEPENDENCIESLOG >> >> # Configure the loggers that write to file. >> log4j.appender.DEPENDENCIESLOG=org.apache.log4j.RollingFileAppender >> log4j.appender.DEPENDENCIESLOG.File=${catalina.base}/logs/dependencies.log >> log4j.appender.DEPENDENCIESLOG.layout=org.apache.log4j.PatternLayout >> log4j.appender.DEPENDENCIESLOG.layout.ConversionPattern=%d{ISO8601} %r >> [%t] %-5p %c %x - %m%n >> log4j.appender.DEPENDENCIESLOG.MaxFileSize=100KB >> log4j.appender.DEPENDENCIESLOG.MaxBackupIndex=10 >> >> # Configure the logger that writes to console. >> log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender >> log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout >> log4j.appender.CONSOLE.layout.ConversionPattern=%r [%t] %-5p %c %x - %m%n >> >> </snip> >> >> Blaine Simpson wrote: >> >>> I don't know what you mean by "random prefix". I see no random prefix. >>> >>> As the message is saying that it can't find an appender for a logger, do >>> you have the DEPENDENCIESLOG appender defined properly? Have you >>> defined a rootLogger? Could there be another log4j.properties in your >>> classpath that is being seen before the one you intend to be seen? Is >>> your log4.properties really at the root level of some element of your >>> runtime classpath? >>> >>> I don't remember if log4j loads the properties file with a context >>> (thread) ClassLoader or a Class ClassLoader, but if you're using complex >>> framework like J2EE or Spring, the Log4j class may not have visibility >>> to the properties file, depending on where you put it. >>> >>> If you want me to test the contents of your log4j.properties file, >>> you'll have to send the whole file. I can fix up platform-specific file >>> paths and such. >>> >>> >>> On 04/21/2010 07:45 AM, Timothy Astle wrote: >>> >>> >>>> Hi all, >>>> >>>> I'm setting up a log4j.properties file to log the HSQLDB server >>>> information to a log file. I have the server set to load from within a >>>> web application. Below is a snip of the startup console log: >>>> >>>> [Server@5a74a7]: [Thread[main,5,main]]: checkRunning(false) entered >>>> [Server@5a74a7]: [Thread[main,5,main]]: checkRunning(false) exited >>>> [Server@5a74a7]: Initiating startup sequence... >>>> [Server@5a74a7]: Server socket opened successfully in 2 ms. >>>> log4j:WARN No appenders could be found for logger >>>> (HSQLDB2820296250.org.hsqldb.persist.Logger). >>>> log4j:WARN Please initialize the log4j system properly. >>>> >>>> This is my entry in my log4j.properties file: >>>> >>>> log4j.logger.org.hsqldb=ERROR, DEPENDENCIESLOG >>>> >>>> I have all of my other libraries configured without a problem, it just >>>> seems that this component is the exception. I'm not sure, but it might >>>> be related to the random prefix? Any thoughts or ideas? >>>> >>>> >>>> Thanks in advance! >>>> >>>> Tim >>>> >>>> > > > ------------------------------------------------------------------------------ > _______________________________________________ > Hsqldb-user mailing list > Hsq...@li... > https://lists.sourceforge.net/lists/listinfo/hsqldb-user > |