logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <rgo...@apache.org>
Subject Re: Still looking for help with L4J2 problem...
Date Tue, 09 Apr 2013 13:39:47 GMT
I apologize for not responding sooner.  Can you provide a simple test for this - hopefully
that can run standalone? I suspect you might have found a bug but I would need to test it.

Sent from my iPad

On Apr 2, 2013, at 10:31 AM, Peter DePasquale <peter.depasquale@gmail.com> wrote:

> I posted about this problem about a week ago and am still stuck. In fact,
> I've further reduced the program to a single logger (name="Test") at the
> trace level, and allow for the creation of the default root logger. At this
> point, I can only get output using a root logger that I define. The named
> logger (Test) creates the file to write to, but I can't get anything
> produced to that file.
> 
> I'm hoping this last cry for help might yield some guidance.  Thanks...
> =====
> I've been trying to track down a failure to log in my Tomcat application.
> In doing so, I've written a small Test class in which I log .entry(),
> .exit(), .trace(), and error() events (source code is below).
> 
> I've also copied the log4j2.xml file and the output files created by the
> logging system (beta4). What I don't understand is why all TRACE and ERROR
> messages end up only in the trace file, and the error file is empty.
> 
> My understanding is that the trace and error messages would be logged in
> the trace file. However, it was my intention to log error events in the
> error file created by the root logger.  Why are error events not being
> passed to the root, or why is root not writing them out? If additivity is
> implicitly enabled, should not all the events be passed to the root logger,
> and that root would only process those error events passed to it?
> 
> log4j2.xml
> ========
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="debug">
> <properties>
> <property
> name="errorLog">${sys:catalina.base}/logs/comtor-log-errors.txt</property>
> <property
> name="traceLog">${sys:catalina.base}/logs/comtor-log-trace.txt</property>
> </properties>
> 
> <appenders>
> <File name="errorFile" fileName="${errorLog}" suppressExceptions="false"
> append="false">
> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %C.%M [%t] - %msg%n"/>
> </File>
> 
> <File name="traceFile" fileName="${traceLog}" suppressExceptions="false"
> append="false">
> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %C.%M [%t] - %msg%n"/>
> </File>
> </appenders>
> <loggers>
> <root level="error">
> <appender-ref ref="errorFile"/>
> </root>
> 
> <logger name="Test" level="trace">
> <appender-ref ref="traceFile"/>
> </logger>
> 
> </loggers>
> </configuration>
> 
> Test.java
> =======
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> import org.apache.logging.log4j.Logger;
> import org.apache.logging.log4j.LogManager;
> 
> public class Test extends HttpServlet {
> private static Logger logger = LogManager.getLogger(Test.class.getName());
> 
> /**
> * Called by the server (via the service method) to allow a servlet to
> handle a GET request.
> * See {@link
> http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServlet.html#doGet(
> *       javax.servlet.http.HttpServletRequest,
> javax.servlet.http.HttpServletResponse)}
> */
> public void doGet(HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException {
> logger.entry();
> logger.error("Error message.");
> logger.trace("Trace message.");
> logger.exit();
> }
> }
> 
> comtor-log-trace.txt
> ==============
> $ more comtor-log-trace.txt
> 2013-03-25 13:23:11 TRACE Test.doGet [http-bio-80-exec-55] -  entry
> 2013-03-25 13:23:11 ERROR Test.doGet [http-bio-80-exec-55] - Error message.
> 2013-03-25 13:23:11 TRACE Test.doGet [http-bio-80-exec-55] - Trace message.
> 2013-03-25 13:23:11 TRACE Test.doGet [http-bio-80-exec-55] -  exit
> 
> comtor-log-error.txt
> ==============
> <empty file>
> -- 
> Peter J. DePasquale, Ph.D.
> Department of Computer Science
> The College of New Jersey
> (e) depasqua [at] tcnj [dot] edu
> (p) 609-771-2806
> (f) 609-637-5190
> (o) Holman Hall - Room 238
> (l) Holman Hall - Room 255

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message