草庐IT

java - 在 Eclipse 中禁用来自 MongoDB 的控制台日志记录

coder 2023-11-02 原文

我正在使用 Mongo 数据库来存储来 self 的 Java 程序的信息。 我正在使用 Eclipse 和 MongoDB 3.0 我遇到的问题是,每当我的程序与 Mongo 进行任何交互时,它都会用来自 JULLogger 的红色文本填充控制台。

我目前没有任何代码来设置记录器级别,因为我在此处或在线其他地方找到的所有示例都给出了错误:

    Logger mongoLogger = Logger.getLogger( "org.mongodb.driver" );
    mongoLogger.setLevel(Level.SEVERE); 

   "The method getLogger(String) is undefined for the type Logger"

这是输出:

    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: Cluster created with settings {hosts=[127.0.0.1:27017],     
    mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description  
    ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=127.0.0.1:27017, 
    type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: Opened connection [connectionId{localValue:1, serverValue:117}] to 127.0.0.1:27017
    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: Monitor thread successfully connected to server with description 
    ServerDescription{address=127.0.0.1:27017, type=STANDALONE, 
    state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 7]}, 
    minWireVersion=0, maxWireVersion=3, electionId=null,    
    maxDocumentSize=16777216, roundTripTimeNanos=587005}
    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: Opened connection [connectionId{localValue:2, serverValue:118}] to 127.0.0.1:27017
    Document{{_id=567045259311932a6406b4e2, time=16:51:48, data=[31C, 38C, 20C]}}
    Dec 16, 2015 8:49:58 AM com.mongodb.diagnostics.logging.JULLogger log
    INFO: Closed connection [connectionId{localValue:2, serverValue:118}] to        
    127.0.0.1:27017 because the pool has been closed.

谁能告诉我如何从我的控制台中删除所有 Mongo 日志?

最佳答案

非常感谢罗斯的建议:

java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(java.util.log‌ ging.Level.SEVERE);

事实上正确的代码是这样的,所以只是一个小改动:

java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(Level.SEVERE);

我可以确认我在运行时不再从控制台中的 mongo 接收任何日志。

关于java - 在 Eclipse 中禁用来自 MongoDB 的控制台日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34307617/

有关java - 在 Eclipse 中禁用来自 MongoDB 的控制台日志记录的更多相关文章

  1. Ruby Readline 在向上箭头上使控制台崩溃 - 2

    当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby​​安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少

  2. ruby - Sinatra:运行 rspec 测试时记录噪音 - 2

    Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/

  3. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  4. ruby-on-rails - 带 Spring 锁的 Rails 4 控制台 - 2

    我正在使用Ruby2.1.1和Rails4.1.0.rc1。当执行railsc时,它被锁定了。使用Ctrl-C停止,我得到以下错误日志:~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`gets':Interruptfrom~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`verify_server_version'from~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.

  5. ruby-on-rails - openshift 上的 rails 控制台 - 2

    我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新ruby​​gems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems

  6. ruby-on-rails - Rails 5 Active Record 记录无效错误 - 2

    我有两个Rails模型,即Invoice和Invoice_details。一个Invoice_details属于Invoice,一个Invoice有多个Invoice_details。我无法使用accepts_nested_attributes_forinInvoice通过Invoice模型保存Invoice_details。我收到以下错误:(0.2ms)BEGIN(0.2ms)ROLLBACKCompleted422UnprocessableEntityin25ms(ActiveRecord:4.0ms)ActiveRecord::RecordInvalid(Validationfa

  7. java - 从 JRuby 调用 Java 类的问题 - 2

    我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www

  8. java - 我的模型类或其他类中应该有逻辑吗 - 2

    我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我

  9. java - 什么相当于 ruby​​ 的 rack 或 python 的 Java wsgi? - 2

    什么是ruby​​的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht

  10. Observability:从零开始创建 Java 微服务并监控它 (二) - 2

    这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/

随机推荐