-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chris,
On 6/8/2009 10:49 PM, Christopher Piggott wrote: > I just switched from Tomcat 5.5 to Tomcat 6 on an Ubuntu server. Are you using the Ubuntu-managed version of Tomcat, or are you using one that you installed from an official package from apache.org? > I'm trying to use log4j with this configuration: [Do you have Tomcat configured to use log4j in the first place?] > log4j.appender.R=org.apache.log4j.ConsoleAppender > log4j.appender.R.target=System.out > log4j.appender.R.layout=org.apache.log4j.PatternLayout > log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n I've never used the "target" property... is this actually a thing? ConsoleAppender should already send messages to stdout. > This was not working, so I searched documentation and learned about: > > <Context swallowOutput="true"> ... </Context> This setting will capture information sent to stdout by a particular application and instead send it to the application log (which, presumably will be sent to a file). If you just want to send your log4j logs to a file, why not use log4j's /file/ logging capabilities instead of piping everything around? > However, this swallowOutput doesn't seem to work. I tried putting > this in several places: > > 1) in the sever-wide context.xml, which already exists and has a > <Context ...> element. (On my system, this file is in /etc/tomcat6). This is probably not a good place to put this setting: it will affect /all/ webapps deployed into Tomcat. If you're using a package-managed version of Tomcat (from Ubuntu) then this file is probably relevant. If you installed your own from an official package, this file is probably just garbage left behind from another installation of Tomcat. > 2) There was no host-specific one, so I added the file > /etc/tomcat6/Catalina/localhost/context.xml with the contents: > <Context swallowOutput="true"/> This file will control the settings for a webapp called "context", which is probably not what you meant. If you want to define the configuration for a webapp called "foo" then your file needs to be called "foo.xml" (but still contain the same stuff you have above). The best place to put your context.xml file is in META-INF/context.xml within your webapp's WAR file (or exploded WAR file where you deploy your app). Then you don't have to worry about where that config file goes on the disk. > 3) Just to exhaust all possibilities, in my webapp's META-INF, I > created a context.xml file with the same contents. > > None of these three things had any effect. It's possible that all configs are fighting each other. Roll-back everything and only do #3 above, then see how it goes. > I tried it both with log4j > and, to rule out that log4j was the problem, tried some > System.out.println and System.err.println here and there. Near as I > can this output goes nowhere. It would be good to get this working without log4j in the mix... your System.out tests should be sufficient to prove that swallowOutput /is/ working. > I would REALLY like my log4j output to go to localhost_<datetime>.log. > Otherwise, I think I have to do some screwing around with the > security manager in order to use something like the > RollingFileAppender. Aah... now it makes sense that you are using log4j + ConsoleAppender + awallowOutput="true". Okay, I think this approach makes sense, but something is obviously misconfigured somewhere. > I tried to follow http://tomcat.apache.org/tomcat-6.0-doc/logging.html > as best I could, including using tomcat-juli.jar from output/extras as > well as adding in tomcat-juli-adapters.jar. I'm not sure if that > really applies, but was wondering .... I don't think you need to do all of this... the out-of-the box logging mechanism should work with swallowOutput="true". It's possible that the Ubuntu packagers have done something that is making this difficult. Have you checked your logging.properties file (somewhere in the Tomcat install or /etc/tomcat5 or something like that) to see that it is sane? You might want to cross-post to an Ubuntu forum to ask over there if there's something Ubuntu-specific that might be causing a problem. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkouu9cACgkQ9CaO5/Lv0PDCBgCgkfhEhZxKOAWtjot6e0kDt1uP TxMAnir+5Wf31VkfayQRu8PG8Uwkw2iX =+vFJ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org