當我嘗試使用SMTP追加程序時,我得到一個奇怪的錯誤在控制檯中。加載XML文件時出現此錯誤,因爲它不會通過除stdout之外的任何輸出流進行記錄。 appender的內容如下(我確認錯誤在這個XML塊中)。我已刪除我們的服務器信息。
<SMTP name="Mailer">
<Subject>[ERROR] (software name) on ${hostName} has thrown a fatal error</Subject>
<To>(a valid email in the form of [email protected])</To>
<From>(a valid email in the form of [email protected])</From>
<SMTPHost>(The Internal IP address of a server in the form of 192.168.0.1)</SMTPHost>
<SMTPPort>587</SMTPPort>
<BufferSize>512</BufferSize>
</SMTP>
無論它是在記錄中引用,我立即收到以下錯誤一旦運行該程序,並從日誌管理器運行getLogger。我已經刪除了一些文件名,並用粗略描述了該文件在這一點上的作用來替換它們。
2015-05-19 19:08:18,812 ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.SmtpAppender for element SMTP. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:137) at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766) at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706) at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698) at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358) at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:361) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:426) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:442) at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175) at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:426) at (Our Log Interface Class, which essentially just returns the log passed by the Apache log manager) at (The global variable definition file, the first method to use getLogger) at (The main method for our software, where the globals are loaded) Caused by: java.lang.NoSuchMethodError: javax.mail.Session.setProtocolForAddress(Ljava/lang/String;Ljava/lang/String;)V at org.apache.logging.log4j.core.net.SmtpManager$SMTPManagerFactory.createManager(SmtpManager.java:325) at org.apache.logging.log4j.core.net.SmtpManager$SMTPManagerFactory.createManager(SmtpManager.java:299) at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:71) at org.apache.logging.log4j.core.net.SmtpManager.getSMTPManager(SmtpManager.java:124) at org.apache.logging.log4j.core.appender.SmtpAppender.createAppender(SmtpAppender.java:142) ... 21 more
2015-05-19 19:08:18,814 ERROR Null object returned for SMTP in Appenders. 2015-05-19 19:08:18,819 ERROR Unable to locate appender Mailer for logger fatalerror
的配置的詳細信息是正確的(我知道這是一個有效的IP等) - 他們的log4j 1.工作錯誤日誌告訴我幾乎一無所知的錯誤,所以我希望有人聽說過這之前。感謝大家!
您需要將'$ {hostName}'更改爲'$ {sys:hostName}'。 –
好,但實際上這不是我們的問題。這是該軟件使用的郵件API多年未更新。 –