aspose file tools*
The moose likes Servlets and the fly likes In tomcat6, System.err.println or System.out.println don't seem to work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "In tomcat6, System.err.println or System.out.println don Watch "In tomcat6, System.err.println or System.out.println don New topic
Author

In tomcat6, System.err.println or System.out.println don't seem to work

Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
I know I'm bound to be doing something stupid. This is code I haven't worked on in about two years, then on tomcat 5, and I set up a brand new tomcat6 server and began to work on it again.

Note the log.write's in here, and the initDB, initAppInfo, etc.:

Here is log.write:

And, here's catalina*.log:

Aug 4, 2009 9:03:34 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Aug 4, 2009 9:03:34 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 753 ms
Aug 4, 2009 9:03:34 PM org.apache.catalina.users.MemoryUserDatabase save
WARNING: User database is not persistable - no write permissions on directory
Aug 4, 2009 9:03:34 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 4, 2009 9:03:34 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
Aug 4, 2009 9:03:35 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class utils
.AppInitializer
java.lang.NullPointerException
at dbMgr.dbUtils.dbGetMaxSessions(dbUtils.java:99)
at utils.AppInitializer.initAppInfo(AppInitializer.java:92)
at utils.AppInitializer.contextInitialized(AppInitializer.java:38)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7
91)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.
java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553
)

You can see that it got an exception in initAppInfo (third line into exception print), but none of the prior System.err.println or System.out.println's printed.

TIA,
anw


-------<br />Thanks & regards,<br />anw
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'd suspect the default config is different.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Why are you rolling your own logging? Log4J and/or Commons Logging is a snap to use.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
David Newton wrote:I'd suspect the default config is different.

Right. I've done a little more rooting around, and changed my logging.properties to this (info-dev is the hostname of the development computer I'm using):

So now I've got a separate info-dev log, which I guess is a good thing, but all it has in it is the prior-noted exceptions; it still doesn't have the println output. Is there any were else it could be configured, or could log files be stored elsewhere? This must be something trivial I'm missing. Does anything need to be configured in the server.xml or within the <Context> tags?

[ Why are you rolling your own logging? Log4J and/or Commons Logging is a snap to use.

I know, I know...but I just got the brand new version of tomcat up and running and went back to this code after two years, and this was the first thing that broke. I do feel like I need to understand what's going on, even if I redo the logging to be more standard. Is commons logging the same thing as java.util.logging?

Thanks for the help!
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
P. S.

I've also tried adding to the <Context> tag.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No; Commons Logging is a wrapper API that provides a common interface for several underlying loggers, including Log4J, Java's logging, etc. (There are a few issues with it, but nothing that should be a problem for what you're doing there.)

If nothing else you could consider replacing the write() internals w/ a real logger--or just bite the bullet and do it right throughout. That said, I don't have an issue println-ing under TC6.
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
Replacing the guts of the write() method may be a way to go, but it is frustrating not to be able to figure out why the basic system calls won't work. I know it must be something trivial I'm missing. The main problem with "doing logging write" (pun intended) is that the whole web app uses it throughout.
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
Any more suggestions? I still haven't gotten this to work.
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
New data point: when I set the handler in my logging.properties file thusly,

I get 0 bytes in the info-dev log (which used to have the aforementioned expception in it). Where is my console going?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: In tomcat6, System.err.println or System.out.println don't seem to work