我在我的JSF应用程序中实现了log4j日志记录。我的log4j.properties文件是这样的
log4j.rootLogger=DEBUG, stdout, fileout
#----------------------------- All logging to console-----------------------------
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] [%t] %5p %c{1}:%L - %m%n
# ------------------------------ All Logging to File------------------------------
log4j.appender.fileout = org.apache.log4j.RollingFileAppender
log4j.appender.fileout.layout = org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern = [%d] [%t] %5p %c{1}:%L - %m%n
log4j.appender.fileout.File = ${catalina.home}/logs/Portal-alllogs.log
log4j.appender.fileout.MaxFileSize =2MB
log4j.appender.fileout.MaxBackupIndex =2
现在我的应用程序中出现以下异常,因为数据库已关闭
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-01034: ORACLE not available
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:361)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:485)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
WARNING: Failed to register in JMX: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01034: ORACLE not available
问题是上面的异常显示在catalina.out中,但不在我的日志文件中
任何人都可以解释一下原因吗? 提前致谢
更新:我只是在部署WAR文件时看到此日志
WARNING: Unexpected exception resolving reference
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
at org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
at org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.getObjectInstance(BasicDataSourceFactory.java:156)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1021)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1021)
at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:631)
at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:237)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
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:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
答案 0 :(得分:0)
这可能是权限问题 - 请检查$ {catalina.home} / logs目录的所有者和权限。
答案 1 :(得分:0)
您是否在代码中捕获该异常并处理它,即记录它?如果没有,为什么你希望出现在你的日志中?
答案 2 :(得分:0)
如果它不是权限问题:验证$ {catalina.home}解析到你认为它的位置 - 尝试使用“原始”绝对路径来排除这种情况。
答案 3 :(得分:0)
你确定异常实际上是LOGDED到stdout,而不仅仅是打印到stdout吗?你能看到你的控制台上的转换模式吗?