2014-10-22 40 views
2

我使用嵌入式数据库(plocal)启动我的应用程序。 OrientDB版本是2.0 M2。如何使用slf4j登录嵌入式orientdb数据库

ODatabasePoolBase<ODatabaseDocumentTx> pool = new ODatabaseDocumentPool("plocal:" + database, getUsername(), getPassword()); 

在我的应用程序使用SLF4J与 “Log4j的2 SLF4J绑定” 的记录。

我看到我的应用程序在日志文件中生成的任何日志消息。 现在我想获取相同日志文件中的orientdb服务器日志消息以进行调试。

我想什么(失败)至今:

  • 07月到SLF4J-1.7.7.jar添加到类路径,并呼吁 SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); 在启动时。

回答

0

OrientDB Server使用自己的LogFormatter。要通过您的应用程序调用相同的内容:

OLogManager.installCustomFormatter(); 

LogFormatter由服务器自动安装。要禁用它,请将orientdb.installCustomFormatter的设置定义为false。例如:

java ... -Dorientdb.installCustomFormatter=false=false ... 

欲了解更多信息,看看官方文档:

<dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jul-to-slf4j</artifactId> 
    </dependency> 

添加到您的initialiation: http://orientdb.com/docs/2.0/orientdb.wiki/Logging.html

0

记录可以通过添加七月到SLF4J到类路径来实现代码

SLF4JBridgeHandler.removeHandlersForRootLogger(); 
    SLF4JBridgeHandler.install(); 
    java.util.logging.Logger logger = java.util.logging.Logger.getLogger("com.orientechnologies"); 
    logger.setLevel(Level.ALL); 

现在你可以se t log4j配置中的单个日志级别:

<Logger name="com.orientechnologies" level="INFO" /> 
相关问题