Discussion:
[jira] [Created] (LOG4J2-868) Allow shutdown hook registration handling to be customizable
Matt Sicker (JIRA)
2014-10-05 18:46:33 UTC
Permalink
Matt Sicker created LOG4J2-868:
----------------------------------

Summary: Allow shutdown hook registration handling to be customizable
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1


Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.

To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.

The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Matt Sicker (JIRA)
2014-10-05 22:25:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14159729#comment-14159729 ]

Matt Sicker commented on LOG4J2-868:
------------------------------------

Renamed the interface to ShutdownCallbackRegistry. Also making Log4jContextFactory implement it in order to delegate. Thus, a LoggerContextFactory can implement ShutdownCallbackRegistry to get the additional functionality (though that might be a rather convoluted customization of Log4j at that point what with mixing Log4j Core and random parts substituted wholesale).
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Matt Sicker (JIRA)
2014-10-05 22:57:35 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker closed LOG4J2-868.
------------------------------
Resolution: Fixed

Implemented just in time for 2.1. :)
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Ralph Goers (JIRA)
2014-10-15 05:15:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers reopened LOG4J2-868:
--------------------------------

This change can cause Log4j to fail to initialize due to the following AccessControlException. This is a blocker to a release.
ERROR StatusLogger Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory specified in jar:file:/usr/local/jakarta-tomcat/webapps/NextivaDriveBilling/WEB-INF/lib/log4j-core-2.1-SNAPSHOT.jar!/META-INF/log4j-provider.properties java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.util.concurrent.Executors$PrivilegedThreadFactory.<init>(Executors.java:563)
at java.util.concurrent.Executors.privilegedThreadFactory(Executors.java:321)
at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.<init>(DefaultShutdownCallbackRegistry.java:54)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.createShutdownCallbackRegistry(Log4jContextFactory.java:117)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:96)
at org.apache.logging.log4j.core.config.Configurator.getFactory(Configurator.java:154)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:109)
at org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
at org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
at org.apache.logging.log4j.web.Log4jServletContextListener.contextInitialized(Log4jServletContextListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3795)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:884)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:737)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
ERROR StatusLogger LogManager returned an instance of org.apache.logging.log4j.simple.SimpleLoggerContextFactory which does not implement org.apache.logging.log4j.core.impl.Log4jContextFactory. Unable to initialize Log4j.
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Ralph Goers (JIRA)
2014-10-15 05:15:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers updated LOG4J2-868:
-------------------------------
Priority: Blocker (was: Major)
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Priority: Blocker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Matt Sicker (JIRA)
2014-10-15 05:53:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14172035#comment-14172035 ]

Matt Sicker commented on LOG4J2-868:
------------------------------------

I'd recommend changing the {{Executors.privilegedThreadFactory()}} bit to use {{Executors.defaultThreadFactory()}} instead. I wasn't really sure which one would be necessary, but the default one is probably fine.
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Priority: Blocker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Ralph Goers (JIRA)
2014-10-15 15:15:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers resolved LOG4J2-868.
--------------------------------
Resolution: Fixed

switched to defaultThreadFactory as suggested. It seems to be working fine.
Post by Matt Sicker (JIRA)
Allow shutdown hook registration handling to be customizable
------------------------------------------------------------
Key: LOG4J2-868
URL: https://issues.apache.org/jira/browse/LOG4J2-868
Project: Log4j 2
Issue Type: New Feature
Components: Core
Affects Versions: 2.0.2
Reporter: Matt Sicker
Assignee: Matt Sicker
Priority: Blocker
Fix For: 2.1
Besides the ability to enable or disable the shutdown hook, there should be a ShutdownRegistrationStrategy interface for customizing how to register a shutdown callback in LoggerContext. This will allow application servers to specify their own class that can register the shutdown callback for a LoggerContext.
To make this really flexible, Log4jContextFactory should be the class that creates the ShutdownRegistrationStrategy.
The basic idea behind this feature is already implemented. I'd like to make this API a bit better before 2.1 so we aren't stuck with a useless interface later on.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...