Java log4j:WARN 请正确初始化 log4j 系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1585520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
log4j:WARN Please initialize the log4j system properly
提问by Ishan
How to resolve these following errors... Am I missing some jar file???
如何解决以下这些错误...我是否缺少一些 jar 文件???
log4j:WARN No appenders could be found for logger (smslib).
log4j:WARN Please initialize the log4j system properly.
org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.PortInUseException: Port currently owned by Unknown Windows Application
at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:97)
at org.smslib.modem.AModemDriver.connect(AModemDriver.java:110)
at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:158)
at org.smslib.ServiceStarter.run(Service.java:252)
WaitCommEvent: Error 31
WaitCommEvent: Error 31
采纳答案by duffymo
My first thought was that your log4j XML or properties file wasn't picked up when log4j initialized. Make sure one of them is in your CLASSPATH.
我的第一个想法是在 log4j 初始化时没有选取您的 log4j XML 或属性文件。确保其中之一在您的 CLASSPATH 中。
A more careful reading of your exception suggests that you're trying to use a port that a Windows app already has taken control of.
更仔细地阅读您的异常表明您正在尝试使用 Windows 应用程序已经控制的端口。
Do a "netstat -a" to see what ports are currently in use and what's attached to them. Pick another one for your log4j appender to use.
执行“netstat -a”以查看当前正在使用的端口以及连接到它们的端口。选择另一个供您的 log4j appender 使用。
Have you written a custom appender to write log messages to SMS? Something elseis using the port you've chosen.
您是否编写了自定义 appender 来将日志消息写入 SMS? 其他东西正在使用您选择的端口。
EDIT:
编辑:
The jre/lib directory is not in the CLASSPATH. You should not be putting anyof your code in that directory. It should end up in the directory where your compiled .class files are written to.
jre/lib 目录不在 CLASSPATH 中。您不应该将任何代码放在该目录中。它应该在你编译的 .class 文件被写入的目录中结束。