facebook

how to attach to web app log file when debugging? [Closed]

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

    Nathan
    Member

    OS: OSX 10.2.8
    Eclipse: 3.0M4 Build id: 200310101454
    Fresh install for MyEclipse (no other plugins installed)
    MyEclipse: 3.6.3
    java version “1.4.1_01”
    Using same version of java to launch Tomcat 4.1.2x

    I was wondering if you could help me understand how the console works when debugging a webapp on Tomcat.

    If I start tomcat from outside of eclipse / MyEclipse, I have all of my app’s log information sent to “myapplication.log” using log4j….When I start tomcat to debug using eclipse /Myeclipse, however, I only see the results of what would normally be catalina.out. My “myapplication.log” file never gets written to, nor can I see the output of my log.debug(“some log stuff”) statements in the eclipse console…..Do you know how I can get access to “myapplication.log” from eclipse when using MyEclipse to start tomcat??

    Thanks
    -nathan

    #199599 Reply

    support-michael
    Keymaster

    When you launch TC from commandline what additional information are you providing to enable log4j logging? By default everything TC echos to stdout/stderr will be displayed in the MyEclipse console view. So my guess is there is log4j configuration information that needs to be included on the Tomcat connector’s JVM preferences. Let us know what you find out.

    Regards,

    Michael
    MyEclipse Support

    #199654 Reply

    Nathan
    Member

    When I launch TC from commandline I don’t pass any additional information…But I do have a log4j.properties file in my WEB-INF/classes dir that contains logging preferences (see below). I’m using Log4J implementation via the jakarta commons logging Log interface……This gives me the capability to do things like automatically email myself if error conditions occur….but like I said, when I start TC from the command line (no special arguments) using $CATALINA_HOME/bin/startup.sh my application writes a log file called hris.log, but when I start it with MyEclipse, hris.log never get added to, nor do I see the logging output in the console in the IDE….

    Contents of log4j.properties:

    # The root logging configuration
    log4j.rootCategory=ERROR, mail, rolling

    # Custom package log levels. For now, I want extra logging output for
    # my own classes and related tools.
    log4j.logger.tahc.hris=DEBUG
    log4j.logger.net.sf.hibernate=ERROR
    log4j.logger.org.apache.commons=ERROR
    log4j.logger.org.apache.struts=ERROR

    # Logging configuration for stdout (will go to catalina.out on tomcat)
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=[%p] %d{DATE} %c – %m%n

    # Logging configuration for the hris.log file
    log4j.appender.rolling=org.apache.log4j.RollingFileAppender
    log4j.appender.rolling.File=hris.log
    log4j.appender.rolling.MaxFileSize=15MB
    log4j.appender.rolling.MaxBackupIndex=3
    log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
    log4j.appender.rolling.layout.ConversionPattern=[%p] %d{DATE} %c – %m%n

    # Configuration for receiving e-mails when ERROR messages occur.
    log4j.appender.mail=org.apache.log4j.net.SMTPAppender
    log4j.appender.mail.To=jpitts@tahc.state.tx.us
    log4j.appender.mail.From=jpitts@tahc.state.tx.us
    log4j.appender.mail.SMTPHost=tahc.state.tx.us
    log4j.appender.mail.Threshold=ERROR
    log4j.appender.mail.BufferSize=1
    log4j.appender.mail.Subject=HRIS Application Error
    log4j.appender.mail.layout=org.apache.log4j.PatternLayout
    log4j.appender.mail.layout.ConversionPattern=[%p] %d{DATE} %c – %m%n

    #199656 Reply

    Scott Anderson
    Participant

    Nathan,

    So, did you put your log4j.properties file under the root of your project’s source folder so it will be added to WEB-INF/classes for you? When you deploy the application is your log4j.properties file deployed where it should be?

    –Scott
    MyEclipse Support

    #199657 Reply

    Nathan
    Member

    Ooops…disregard this thread — I figured out my problem. The first line in my log4j.properties file didn’t have “stdout” after rolling…..should have looked like this:
    log4j.rootCategory=ERROR, mail, rolling, stdout

    Thanks,
    nate

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: how to attach to web app log file when debugging? [Closed]

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