logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter DePasquale <peter.depasqu...@gmail.com>
Subject Still looking for help with L4J2 problem...
Date Tue, 02 Apr 2013 17:31:13 GMT
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?

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">

<File name="errorFile" fileName="${errorLog}" suppressExceptions="false"
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %C.%M [%t] - %msg%n"/>

<File name="traceFile" fileName="${traceLog}" suppressExceptions="false"
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %C.%M [%t] - %msg%n"/>
<root level="error">
<appender-ref ref="errorFile"/>

<logger name="Test" level="trace">
<appender-ref ref="traceFile"/>


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
 *       javax.servlet.http.HttpServletRequest,
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.error("Error message.");
logger.trace("Trace message.");

$ 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

<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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message