[
https://issues.apache.org/jira/browse/LOG4J2-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13774222#comment-13774222
]
Remko Popma commented on LOG4J2-379:
------------------------------------
On closer inspection it seems that the error occurs when the
{{OnStartupTriggeringPolicy}} class is being loaded.
Which means that we can't even {{import
java.lang.management.ManagementFactory;}} without ticking off Google App
Engine...
Since this is a once-only initialization and performance impact will be
negligible we can use reflection to try and call
{{ManagementFactory.getRuntimeMXBean().getStartTime()}}.
If that fails, I propose we use System.currentTimeMillis instead.
This means that on Google App Engine, using {{OnStartupTriggeringPolicy}}
results in log files older than _Log4j initialization time_ will be rolled
over. (In other environments the behavior is still: log files older than the
current JVM's start time are rolled over.)
Thoughts?
> Problem using log4j2 in Google App Engine
> -----------------------------------------
>
> Key: LOG4J2-379
> URL: https://issues.apache.org/jira/browse/LOG4J2-379
> Project: Log4j 2
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0-beta8
> Environment: Google App Engine
> Reporter: Remko Popma
> Assignee: Remko Popma
>
> {code}
> [INFO] Caused by: java.lang.NoClassDefFoundError:
> java.lang.management.ManagementFactory is a restricted class. Please see the
> Google App Engine developer's guide for more details.
> [INFO] at
> com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
> [INFO] at
> org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy.<clinit>(OnStartupTriggeringPolicy.java:33)
> [INFO] at java.lang.Class.forName0(Native Method)
> [INFO] at java.lang.Class.forName(Class.java:186)
> [INFO] at
> org.apache.logging.log4j.core.config.plugins.PluginManager.decode(PluginManager.java:222
> {code}
> This seems to be caused by the {{OnStartupTriggeringPolicy}} class
> initializing a static field with this code:
> {code}
> private static final long JVM_START_TIME =
> ManagementFactory.getRuntimeMXBean().getStartTime();
> {code}
> Is there a workaround for this?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]