You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2016/07/11 19:16:11 UTC

[jira] [Commented] (TOMEE-1863) Log4J initialized twice for web app

    [ https://issues.apache.org/jira/browse/TOMEE-1863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15371442#comment-15371442 ] 

Romain Manni-Bucau commented on TOMEE-1863:
-------------------------------------------

Hi,

that's the expected behavior AFAIK, issue can be you use static logger (I know it is a common pattern but it is an anti-pattern in EE land cause of the implied scanning) or log4j doesnt release appenders when classloaders are trashed.

> Log4J initialized twice for web app
> -----------------------------------
>
>                 Key: TOMEE-1863
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1863
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.7.3
>         Environment: Windows Server 2012, Windows 7
>            Reporter: loua
>
> The web application uses slf4j for logging.  The logging implementation is log4j.  The application contains a log4j.properties file in the WEB-INF\classes directory.  The application uses JAX-RS and Stateless EJBs.  Log4j is initialized by the TempClassLoader and then again when the webapp is loaded.  This results in two OS file handles referencing the same log file (RollingLogFileAppender) that prevents the log file from rolling over.  TomEE logging uses the default java.util.logging.
> Log4j Debug Output
> =======================================================
> INFO: Deploying web application archive D:\apps\clean\apache-tomee-plus-1.7.3\webapps\log4jweb.war
> Jul 11, 2016 2:05:48 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
> INFO: ------------------------- localhost -> /log4jweb
> Jul 11, 2016 2:05:48 PM org.apache.openejb.config.ConfigurationFactory configureApplication
> INFO: Configuring enterprise application: D:\apps\clean\apache-tomee-plus-1.7.3\webapps\log4jweb
> log4j: Trying to find [log4j.xml] using context classloader org.apache.openejb.core.TempClassLoader@2e341234.
> log4j: Trying to find [log4j.xml] using org.apache.openejb.core.TempClassLoader@2e341234 class loader.
> log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
> log4j: Trying to find [log4j.properties] using context classloader org.apache.openejb.core.TempClassLoader@2e341234.
> log4j: Using URL [file:/D:/apps/clean/apache-tomee-plus-1.7.3/webapps/log4jweb/WEB-INF/classes/log4j.properties] for automatic log4j configuration.
> log4j: Reading configuration from URL file:/D:/apps/clean/apache-tomee-plus-1.7.3/webapps/log4jweb/WEB-INF/classes/log4j.properties
> log4j: Parsing for [root] with value=[DEBUG, file].
> log4j: Level token is [DEBUG].
> log4j: Category root set to DEBUG
> log4j: Parsing appender named "file".
> log4j: Parsing layout options for "file".
> log4j: Setting property [conversionPattern] to [%d{MM-dd HH:mm:ss,SSS} %-5p %32.32c{1}:%3.3L - %m%n].
> log4j: End of parsing for "file".
> log4j: Setting property [maxBackupIndex] to [9].
> log4j: Setting property [file] to [D:/apps/clean/apache-tomee-plus-1.7.3/logs/log4jweb.log].
> log4j: Setting property [maxFileSize] to [10KB].
> log4j: setFile called: D:/apps/clean/apache-tomee-plus-1.7.3/logs/log4jweb.log, true
> log4j: setFile ended
> log4j: Parsed "file" options.
> log4j: Parsing for [simple] with value=[DEBUG].
> log4j: Level token is [DEBUG].
> log4j: Category simple set to DEBUG
> log4j: Handling log4j.additivity.simple=[null]
> log4j: Finished configuring.
> ...
> INFO: Enterprise application "D:\apps\clean\apache-tomee-plus-1.7.3\webapps\log4jweb" loaded.
> Jul 11, 2016 2:05:48 PM org.apache.openejb.assembler.classic.Assembler createApplication
> INFO: Assembling app: D:\apps\clean\apache-tomee-plus-1.7.3\webapps\log4jweb
> log4j: Trying to find [log4j.xml] using context classloader LazyStopWebappClassLoader
>   context: /log4jweb
>   delegate: false
>   repositories:
>     /WEB-INF/classes/
> ----------> Parent Classloader:
> org.apache.catalina.loader.StandardClassLoader@51521cc1
> .
> log4j: Trying to find [log4j.xml] using LazyStopWebappClassLoader
>   context: /log4jweb
>   delegate: false
>   repositories:
>     /WEB-INF/classes/
> ----------> Parent Classloader:
> org.apache.catalina.loader.StandardClassLoader@51521cc1
>  class loader.
> log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
> log4j: Trying to find [log4j.properties] using context classloader LazyStopWebappClassLoader
>   context: /log4jweb
>   delegate: false
>   repositories:
>     /WEB-INF/classes/
> ----------> Parent Classloader:
> org.apache.catalina.loader.StandardClassLoader@51521cc1
> .
> log4j: Using URL [file:/D:/apps/clean/apache-tomee-plus-1.7.3/webapps/log4jweb/WEB-INF/classes/log4j.properties] for automatic log4j configuration.
> log4j: Reading configuration from URL file:/D:/apps/clean/apache-tomee-plus-1.7.3/webapps/log4jweb/WEB-INF/classes/log4j.properties
> log4j: Parsing for [root] with value=[DEBUG, file].
> log4j: Level token is [DEBUG].
> log4j: Category root set to DEBUG
> log4j: Parsing appender named "file".
> log4j: Parsing layout options for "file".
> log4j: Setting property [conversionPattern] to [%d{MM-dd HH:mm:ss,SSS} %-5p %32.32c{1}:%3.3L - %m%n].
> log4j: End of parsing for "file".
> log4j: Setting property [maxBackupIndex] to [9].
> log4j: Setting property [file] to [D:/apps/clean/apache-tomee-plus-1.7.3/logs/log4jweb.log].
> log4j: Setting property [maxFileSize] to [10KB].
> log4j: setFile called: D:/apps/clean/apache-tomee-plus-1.7.3/logs/log4jweb.log, true
> log4j: setFile ended
> log4j: Parsed "file" options.
> log4j: Parsing for [simple] with value=[DEBUG].
> log4j: Level token is [DEBUG].
> log4j: Category simple set to DEBUG
> log4j: Handling log4j.additivity.simple=[null]
> log4j: Finished configuring.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)