9

Where does tomcat put the System.out.println output ?

I'm not interested in out.println. I'm using a system that uses system.out to log issues, like login success/fail, and I need to look to that generated "log".

Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
Eduardo Moniz
  • 2,095
  • 3
  • 18
  • 27

2 Answers2

8

It usually prints to catalina.out.

It is highly unrecommended to log using system.out.println() from several reasons:

  • you cannot control which messages are logged and which aren't unless you change the code
  • catalina.out just grow all the time, and you cannot move it so that tomcat will create another one.

A better solution is to use one of the popular (and mature) logging frameworks:

A good solution which is backed by log4j, is to use Jakarta's log tag library, where you can have your logging messages in any of this forms

<log:info message="this is a message"/>

<log:info category="foo.bar" message="this is a message"/>

<log:info category="foo.bar">
  this is a message
</log:info>
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
  • 1
    The author of Log4J left the project and is working on logback (for some time already) which works in combination of slf4j. Both should be the preferred logging frameworks. – bric3 Nov 24 '11 at 17:27
  • 1
    @Brice I agree, SLF4J is my preference these days as well. It also has a JSP tag library, documented at http://www.slf4j.org/taglib/ – David Rabinowitz Nov 26 '11 at 21:12
3

CATALINA_HOME/logs/stdout_YYYYMMDD.log

is the default, where CATALINA_HOME is your base Tomcat directory. There are various ways to change this programatically and via configuration.

Robert Campbell
  • 6,848
  • 12
  • 63
  • 93
  • $ ls /usr/local/tomcat/logs admin.2009-10-06.log catalina.2009-10-06.log catalina.out host-manager.2009-10-06.log localhost.2009-10-06.log manager.2009-10-06.log tomcat.log in none of this files i notice any change with a system.out.println, where should this configuration be ? tnx! – Eduardo Moniz Oct 09 '09 at 16:17
  • What version of Tomcat are you running? – Robert Campbell Oct 12 '09 at 08:08