Results 1 to 3 of 3
  1. #1
    devin is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default Log4j not printing out file and line number

    Hi,

    I am making a web application while learning JSP, tomcat and struts. I am using Log4j to do some logging but it is not working completely as expected. Here is my Log4j conf:

    Java Code:
    log4j.rootLogger=WARN, STDOUT, ROLLFILE
    log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
    log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
    log4j.appender.STDOUT.layout.ConversionPattern=[%d{yyyy-MMM-dd hh:mm}] %5p [%t] (%F\:%L) - %m%n
    #
    log4j.appender.ROLLFILE=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.ROLLFILE.File=/var/www/marlowe_dev/WEB-INF/logs/com.marlowe.log
    log4j.appender.ROLLFILE.layout=org.apache.log4j.PatternLayout
    log4j.appender.ROLLFILE.layout.ConversionPattern=[%d{yyyy-MMM-dd hh:mm}] %5p [%t] (%F\:%L) - %m%n
    log4j.appender.ROLLFILE.DatePattern='.'yyyy-MM-dd-a
    log4j.appender.R.MaxFileSize=100KB
    log4j.appender.R.MaxBackupIndex=1
    # main logger
    log4j.logger.com.marlowe=DEBUG

    I have logging in a Filter servlet and in a class. I put some logging in a method that is called when a URL is hit and that is called from my unit test from main. When I run the unit test, it logs perfectly. When I hit a URL and the logging runs it doesn't print out the file and line number. It prints out '?' where the file and line number should be. Is there a configuration setting in tomcat I need to set?

    Thanks.

  2. #2
    binlee is offline Member
    Join Date
    Feb 2009
    Posts
    3
    Rep Power
    0

    Default

    Can you post your code?

  3. #3
    devin is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Thanks for your reply.

    Here is my code. This is a filter that gets hit on every request:
    Java Code:
    @Override public void doFilter(ServletRequest request,
                           ServletResponse response,
                           FilterChain chain)
          throws ServletException, IOException {
         HttpServletRequest req = (HttpServletRequest)request;
        HttpServletResponse res = (HttpServletResponse)response;
    
        Logger logger = Logger.getLogger("com.marlowe");
        logger.info("Devin was here in reporter");
    
        chain.doFilter(request,response);
      }
    I also have another object that gets used on every request and it has the exact same logging code and when I run that from the command line it prints the file an line number, but when the same code gets hit from the web it doesn't. This makes me think this is a tomcat setting or something, but I don't know.

    Thanks for any help.

Similar Threads

  1. read the file from different line number
    By vaskarbasak in forum Advanced Java
    Replies: 3
    Last Post: 06-02-2008, 01:31 PM
  2. Issue with printing line
    By Azndaddy in forum Advanced Java
    Replies: 1
    Last Post: 04-04-2008, 07:37 PM
  3. Printing command line arguments
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 09:27 AM
  4. line number
    By kazitula in forum New To Java
    Replies: 3
    Last Post: 11-21-2007, 10:27 PM
  5. how to know the number of the line
    By simon in forum New To Java
    Replies: 3
    Last Post: 08-01-2007, 04:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •