• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging strategy

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, what's a better logging strategy for struts2? In Struts 1, I used to create my own LogService using JDK logging as Struts Plug In, which got initialized when application starts. What my log service did is to archive the past application logs and create new logger&handler for different type of logs for my application. In Struts2's XML file, I didn't find corresponding plugIn place to initialize my own application-wise service at startup, and struts-plugIn.xml seems to talk about a different type of plugIn than my old Struts1 plugIn, or is it? Struts2's ActionSupport has a Log static member using Apache commons, is it a better way to handle logging? What's a better strategy of doing logging in Struts2 application, which will not only archive past logs at startup, but also differentiate a different type of logs to different log files. Thanks!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally I'd recommend using something like Log4J, along with its various file-based log appenders.

Dave
 
JW Li
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. But how could we take advantage of the commons.logging.LOG static member in ActionSupport? I think it exists there for a reason... Reading commons.logging documentation, I know the LogFactory will search for different configuration (such as log4J or JDK), but it does not go into details on how to configure for each so that LOG static member in the AcitionSupport class could be helpful (such as writing log to a file, very common requirement for an application, currently without any configuration, my struts2 application log goes to the stdout). Could you give a little bit instruction and analysis on this? In your book, is it covered? Thanks!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The book does not go into detail about configuring every possible logging implementation. I'm not overly-familiar with the member you're referring to; I generally just declare a static Log instance in each of my actions and follow standard Log4J configuration conventions depending on the application's particular logging needs.

Dave
 
JW Li
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! BTW, the member I was talking about is a static member LOG (protected static Log) in com.opensymphony.xwork2.ActionSupport class.
The API could be found at http://struts.apache.org/2.0.11.2/struts2-core/apidocs/index.html

Thanks again for your reply!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like it's just Commons Loggins Log instance, which would use whatever underlying logging implementation the application is configured to use. It's handy, but in general I'd imagine more-specific logs would be used, allowing for a more fine-grained logging configuration.

Dave
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic