我創建了一個Java應用程序並使用該應用程序初始化一個java.util.Logger,並使用jboss AS 7服務器運行該應用程序爲-javaagent
,並且我得到了IllegalStateException
(我正在使用Eclipse IDE中)。在這裏我如下記錄的初始化代碼使用java.util.Logger的JBOSS AS 7.1中的LogManager異常
static public void setup() throws IOException {
// Get the global logger to configure it
Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
logger.setLevel(Level.INFO);
fileTxt = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.txt");
fileHTML = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.html");
// create txt Formatter
formatterTxt = new SimpleFormatter();
fileTxt.setFormatter(formatterTxt);
logger.addHandler(fileTxt);
// create HTML Formatter
formatterHTML = new BMITHtmlFormatter();
fileHTML.setFormatter(formatterHTML);
logger.addHandler(fileHTML);
}
當我創建-javaagent
罐子附有代碼上面的線條和與JBoss AS7服務器我得到下面的異常
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:73)
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.jboss.modules.Module.run(Module.java:260)
at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
at org.jboss.logmanager.log4j.BridgeRepositorySelector.(BridgeRepositorySelector.java:42)
... 7 more
而且我本身運行在4ms內完成,我得到了一個solution,這是打開服務器定義的啓動配置。 並將-logmodule org.jboss.logmanager
添加到org.jboss.as.standalone
之前的程序參數。 但它導致同樣的異常,並帶有一些額外的警告。這裏有例外
WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:73)
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.jboss.modules.Module.run(Module.java:260)
at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
at org.jboss.logmanager.log4j.BridgeRepositorySelector.(BridgeRepositorySelector.java:42)
... 7 more
感謝您的信息 –
謝謝,工作正常! –
在Windows中,語法不同:例如設置「JAVA_OPTS =%JAVA_OPTS%-Djboss.modules.system.pkgs = org.jboss.byteman,org.jboss.logmanager」並設置「JAVA_OPTS =%JAVA_OPTS%-Xbootclasspath/p:%JBOSS_HOME%\ modules \ org \ jboss \ logmanager \ main \ jboss-logmanager-1.3.2.Final.jar –