Results 1 to 3 of 3
- 02-09-2009, 03:52 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
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.
- 02-23-2009, 11:36 AM #2
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
Can you post your code?
- 03-05-2009, 03:16 PM #3
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
Thanks for your reply.
Here is my code. This is a filter that gets hit on every request:
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.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); }
Thanks for any help.
Similar Threads
-
read the file from different line number
By vaskarbasak in forum Advanced JavaReplies: 3Last Post: 06-02-2008, 01:31 PM -
Issue with printing line
By Azndaddy in forum Advanced JavaReplies: 1Last Post: 04-04-2008, 07:37 PM -
Printing command line arguments
By Java Tip in forum Java TipReplies: 0Last Post: 12-03-2007, 09:27 AM -
line number
By kazitula in forum New To JavaReplies: 3Last Post: 11-21-2007, 10:27 PM -
how to know the number of the line
By simon in forum New To JavaReplies: 3Last Post: 08-01-2007, 04:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks