[prev in list] [next in list] [prev in thread] [next in thread]
List: log4j-dev
Subject: [jira] [Comment Edited] (LOG4J2-575) Log4J2 and Tomee Plus 7.0.47 not working
From: "Matt Sicker (JIRA)" <jira () apache ! org>
Date: 2014-03-29 20:54:14
Message-ID: JIRA.12703109.1395613064074.31350.1396126454599 () arcas
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/LOG4J2-575?page=com.atlassian.jira.plugin. \
system.issuetabpanels:comment-tabpanel&focusedCommentId=13954439#comment-13954439 ]
Matt Sicker edited comment on LOG4J2-575 at 3/29/14 8:53 PM:
-------------------------------------------------------------
Scratch that. Confirmed to work properly in Tomcat:
{code}
Using CATALINA_BASE: /usr/local/Cellar/tomcat/7.0.52/libexec
Using CATALINA_HOME: /usr/local/Cellar/tomcat/7.0.52/libexec
Using CATALINA_TMPDIR: /usr/local/Cellar/tomcat/7.0.52/libexec/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
Using CLASSPATH: \
/usr/local/Cellar/tomcat/7.0.52/libexec/bin/bootstrap.jar:/usr/local/Cellar/tomcat/7.0.52/libexec/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.52
Server built: Feb 13 2014 10:24:25
Server number: 7.0.52.0
OS Name: Mac OS X
OS Version: 10.9.2
Architecture: x86_64
JVM Version: 1.8.0-b132
JVM Vendor: Oracle Corporation
{code}
I used the same config given here, and made a simple servlet to test it out:
{code}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(urlPatterns = "/hello/*")
public class Log extends HttpServlet {
private static final Logger LOGGER = LogManager.getLogger();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws \
ServletException, IOException { final String fallback = "World";
final String whom = req.getParameter("whom");
String who = whom == null || whom.isEmpty() ? fallback : whom;
LOGGER.info("Hello, {}!", who);
res.setContentType("text/html; charset=UTF-8");
final PrintWriter writer = res.getWriter();
try {
writer.println("<!DOCTYPE html>");
writer.println("<html><head><title>Hello Servlet</title></head><body>");
writer.append("Hello, ").append(who).append('!').println();
writer.println("</body></html>");
} finally {
writer.close();
}
}
}
{code}
However, I didn't try it with SLF4J or anything, but I doubt that's the issue.
Edit: I should also add that I copied the log4j-api and log4j-core RC1 jars to my \
Tomcat lib/ as well, not included in the war. I'm going to install tomee-plus and try \
it there as well.
was (Author: jvz):
Scratch that. Confirmed to work properly in Tomcat:
{code}
Using CATALINA_BASE: /usr/local/Cellar/tomcat/7.0.52/libexec
Using CATALINA_HOME: /usr/local/Cellar/tomcat/7.0.52/libexec
Using CATALINA_TMPDIR: /usr/local/Cellar/tomcat/7.0.52/libexec/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
Using CLASSPATH: \
/usr/local/Cellar/tomcat/7.0.52/libexec/bin/bootstrap.jar:/usr/local/Cellar/tomcat/7.0.52/libexec/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.52
Server built: Feb 13 2014 10:24:25
Server number: 7.0.52.0
OS Name: Mac OS X
OS Version: 10.9.2
Architecture: x86_64
JVM Version: 1.8.0-b132
JVM Vendor: Oracle Corporation
{code}
I used the same config given here, and made a simple servlet to test it out:
{code}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(urlPatterns = "/hello/*")
public class Log extends HttpServlet {
private static final Logger LOGGER = LogManager.getLogger();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws \
ServletException, IOException { final String fallback = "World";
final String whom = req.getParameter("whom");
String who = whom == null || whom.isEmpty() ? fallback : whom;
LOGGER.info("Hello, {}!", who);
res.setContentType("text/html; charset=UTF-8");
final PrintWriter writer = res.getWriter();
try {
writer.println("<!DOCTYPE html>");
writer.println("<html><head><title>Hello Servlet</title></head><body>");
writer.append("Hello, ").append(who).append('!').println();
writer.println("</body></html>");
} finally {
writer.close();
}
}
}
{code}
However, I didn't try it with SLF4J or anything, but I doubt that's the issue.
> Log4J2 and Tomee Plus 7.0.47 not working
> ----------------------------------------
>
> Key: LOG4J2-575
> URL: https://issues.apache.org/jira/browse/LOG4J2-575
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0-rc1
> Reporter: Alex Gout
> Labels: Log4j2, Logger, TomEE
>
> According to http://logging.apache.org/log4j/2.x/manual/webapp.html, Log4j2 should \
> work with Tomcat7.0.47. I'm using TomEE Plus 7.0.47. I have a webapplication \
> deployed with a log4j2.xml in my web-inf/classes folder. This is the config: \
> {code:xml} <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
> <Appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
> </Console>
> <File name="File" fileName="${sys:catalina.home}/logs/testapp.log">
> <PatternLayout>
> <pattern>%d %p %C{1.} [%t] %m%n</pattern>
> </PatternLayout>
> </File>
> </Appenders>
> <Loggers>
> <Logger name="org.alex" level="TRACE" additivity="false">
> <AppenderRef ref="File"/>
> </Logger>
> <Root level="INFO">
> <AppenderRef ref="Console"/>
> </Root>
> </Loggers>
> </Configuration>
> {code}
> I have a logger declared in a class with name org.alex.util.JSON:
> private static final Logger LOG = LoggerFactory.getLogger(JSON.class);
> I'm using slf4j-api 1.7.5, and have the following libs added to the tomcat lib:
> slf4j-api-1.7.5.jar
> log4j-api-2.0-rc1.jar
> log4j-core-2.0-rc1.jar
> log4j-slf4j-impl-2.0-rc1.jar
> If I change the Configuration status to TRACE, I can see my configuration file \
> being picked up and configuration happens as expected. Also I can see the MBeans \
> being added. However, there's not one logging statement ending up in my logfile \
> (although the file is created). I debugged into the log4j2 Logger, and see that the \
> isEnabled(...) method return false because the logger (com.alex.util.JSON) has the \
> level "ERROR" set, while the configuration set the package org.alex to TRACE. \
> Further investigation shows it uses a DefaultConfiguration configured for \
> level=ERROR, and only root is configured. Furthermore I noticed that the \
> classloader for the instance of my logger that is created at configuration is \
> org.apache.openejb.core.TempClassLoader, while the classloader of the Logger that \
> is invoked is org.apache.catalina.loader.StandardClassLoader. I don't know enough \
> of the whole mechanism to judge whether or not this is to be expected
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic