struts app and adding logging to it using common or jdk14looger - syntax for FileHandler

I would like to add logging to a struts application - but not sure how to

I have common logger set up and it is working but only writes to the console

how in the properties file would I specify an file to put it out to

I ran across this:
Handler fh = new FileHandler("%t/wombat.log");

but I would like it in the properites file


thank you!!

also what goes in the and what should go in the
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you are going to add logging to a struts application then I would suggest using Log4J directly (commons logging will try to use Log4J if you have it).

Log4J requires you to download the jars and place a properties file in the WEB-INF lib.

here's and example of how to configure a properties file


   Log4J Configuration Quick Reference:

   Priority order is DEBUG < INFO < WARN < ERROR < FATAL

   PatternLayout conversion characters:

    %c   Category of the logging event
    %C   Fully qualified class name of the caller
    %d   Date of the logging event  (example: %d{HH:mm:ss,SSS} )
    %F   File name where the logging request was issued (caution: extremely slow
    %l   Location information of the caller (caution: extremely slow)
    %L   Line number from where the logging request was issued (caution: extreme
ly slow)
    %m   Application-supplied message
    %M   Method name from where the logging request was issued (caution: extreme
ly slow)
    %n   Line separator
    %p   Priority of the logging event
    %r   Number of milliseconds since the start of the application
    %t   Name of the thread that generated the logging event
    %x   Nested diagnotic context associated with the thread
    %%   A single percent sign

   Format modifiers examples:

    %20c     Left pad with spaces if category is less than 20 characters long
    %-20c    Right pad with spaces if category is less than 20 characters long
    %.30c    Truncate from the beginning if category is more than 30 chars long
    %20.30c  Left pad 20 chars + truncate from beginning if more than 30 chars
    %-20.30c Right pad 20 chars + truncate from beginning if more than 30 chars

   Examples:  "%r [%t] %-5p %c %x - %m\n"
              "%-6r [%15.15t] %-5p %30.30c %x - %m\n"

#level is debug and goes to stdout and R which we will specify later
log4j.rootLogger=debug, stdout, R


# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n


# log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
# log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

calling the log in a struts action

//normal imports
// Jakarta
import org.apache.log4j.Logger;

public class MyAction extends Action      {
      private static final Logger _LOGGER = Logger.getLogger( MyAction .class.getName() );

      public ActionForward execute(
                  final ActionMapping pMapping,
                  final ActionForm pForm,
                  final HttpServletRequest pRequest,
                  final HttpServletResponse pResponse)
      throws Exception {
   " action has started" ); //make logger call at info level      
        //blah blah return an actionforward  
      } // execute
sahromAuthor Commented:
Thanks very much for you reply.  There is so much more documentation on Log4J, that I would have tried this one to begin with , but I was told they had tried and there was a problem somewhere.  They are using JBoss
Log4J is one of the simplest logging systems to get running so I'm surprised. WHat issues did they ahve or was it just unfamiliarity?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.