facebook

Redirect Tomcat Output [Closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #203922 Reply

    vbfischer
    Member

    Is there any way to redirect Tomcat’s output to a file? The Tomcat Service for Windows XP seems to do it…

    #203923 Reply

    Riyad Kalla
    Member

    If you need Tomcat’s output to go to a file I believe running it via the Windows Services menu or from the command line will be your best bet. When you use the MyEclipse application connectors, they redirect console output to your IDE output window (obviously). I do not believe there is a solution to then redirecting the redirected output BACK to a file from the output window, myabe a plugin for Eclipse exists that will do it?

    #203925 Reply

    vbfischer
    Member

    I need to rethink my requirements. Redirecting Tomcat’s output to a file is a workaround to something I’m having trouble figuring out… Maybe this isn’t the best forum to ask it, but since I started, I’ll post it here…

    The best option is to use a Logging package, such as Log4j, but I’m having difficulty getting it to work.

    I’ve got a basic log4j.properties file specified:
    # Set root category priority to DEBUG and appenders to Console and ConsoleLog
    log4j.rootCategory=DEBUG, ConsoleLog

    # console log
    log4j.appender.ConsoleLog=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.ConsoleLog.DatePattern=’.’yyyy-MM-dd
    log4j.appender.ConsoleLog.File=thelog.log
    log4j.appender.ConsoleLog.layout=org.apache.log4j.PatternLayout
    log4j.appender.ConsoleLog.layout.ConversionPattern=%d %-5p %c{1}.%M – %m%n

    At the top of my servlet, I have:
    private static Logger logger = Logger.getLogger(MyServlet.class);

    When Tomcat starts up, It give the message:
    log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
    log4j:WARN Please initialize the log4j system properly.

    All logger messages display on the console… The file is never created.

    Again, I know that doesn’t belong on this forum, but maybe someone here can point me in the right direction 🙂

    #203928 Reply

    Riyad Kalla
    Member

    I’m going to close this topic so other moderators know its closed, but I’ll still try and see if I can help.

    When you say “All logger messages display on the console”, my questions are:
    1) Is this running using the MyEclipse connectors? If so, what happens when you just run Tomcat from the service menu, does it just go to the stderr or stdout.txt files in the /tomcat/logs dir?
    2) In your properties file you setup a Console appender, not a file appender… why are you expecting this to go to a file?
    3) See how others use log4j from servlets, maybe start here: http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html?page=1

    #203931 Reply

    vbfischer
    Member

    Thanks.

    I found the same information in my log4j manual I bought a while back. Worked like a charm. That onjava article is exactly what I did

    #203933 Reply

    Riyad Kalla
    Member

    Is everything working alright now?

    #204039 Reply

    vbfischer
    Member

    Yep. Working great, and the way I originally wanted it to (without system.out.println’s stuck everywhere). Nice thing about logging packages, especially log4j, is that they can be turned off unless you need them…

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Redirect Tomcat Output [Closed]

You must be logged in to post in the forum log in