facebook

Add Log4j .properties in Struts Project [TIP]

  1. MyEclipse IDE
  2.  > 
  3. Feature Requests
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #216912 Reply

    nupstone
    Member

    Hi,

    I’ve just discovered the easy way to debug struts apps. Add log4j to my WEB-INF/lib folder, and put the following in WEB-INF/classes/log4j.properties

    
    # Global logging configuration
    log4j.rootLogger=ERROR, stdout
    
    # Struts
    log4j.logger.org.apache.struts.action=DEBUG
    
    # My app - based on ibatis pattern
    log4j.logger.com.ibatis.struts.BeanAction=DEBUG
    
    
    # Console output...
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
    
    

    How about configuring some logging by default. It’s great, and would have saved me a day learning the hard way (in total).

    Yep.. I could have bought a book too… but just learned more in 5 mins watching what happens when I navigate a web app than from all I gleaned from PDFs and web pages on Struts.

    😀

    #216951 Reply

    Riyad Kalla
    Member

    I don’t know that we will go changing our wizards right away though as its best for us (as a tool provider) to provide the most default out-of-box experience. This logging information is covered in the Struts docs, so I suppose if anyone was so inclined they would hunt it down or search for this post 😉

    Again thank you for posting it, it is an excellent source of information.

    #216967 Reply

    nupstone
    Member

    Thanks Riyad.
    Yes. The more we share what works, the more chance of finding what we need somewhere like in these forums.

    When you say “most default out-of-box experience”, I don’t get that that works for developers.

    What you provide us with is an IDE, which contains a debugger. I invite you to reconsider the notion of what a debugger is.

    I propose that a powerful debugger is a tool that gives you the fastest route to finding why something didn’t work.

    So, if I were developing the struts code, then a Java source level debugger would be useful. However, if I’m developing Struts-based solutions, especially if I’m only restructuring by making changes to struts-config.xml and to JSP pages, the Java debugger is going to be of little use for me.

    I that case, my “debugger” is having the struts.action package showing me what’s happening.

    I think that a log4j configurator as part of MyEclipse would be awesome, you could turn on/off debug levels from the package tree 😀

    Do you get where we’re coming from here ? Maybe the thing is not so much struts, as giving really quick and direct access to logging for all Web apps.

    Many thanks.

    Neale

    #216980 Reply

    Riyad Kalla
    Member

    Neale,
    As far as being a developer is concerned, I think this is a really cool idea… let me pass it by some others.

    #217229 Reply

    nupstone
    Member

    Yeah… I surprised myself with that one 8)

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Add Log4j .properties in Struts Project [TIP]

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