zoukankan      html  css  js  c++  java
  • 写mongodb日志

    The following steps create and rotate a log file:

    1. Start a mongod with verbose logging, with appending enabled, and with the following log file:

      mongod -v --logpath /var/log/mongodb/server1.log --logappend
    2. In a separate terminal, list the matching files:

      ls /var/log/mongodb/server1.log*

      For results, you get:

      server1.log
      
    3. Rotate the log file using one of the following methods.

      • From the mongo shell, issue the logRotate command from the admin database:

        use admin
        db.runCommand( { logRotate : 1 } )
        

        This is the only available method to rotate log files on Windows systems.

      • From the UNIX shell, rotate logs for a single process by issuing the following command:

        kill -SIGUSR1 <mongod process id>
        
      • From the UNIX shell, rotate logs for all mongod processes on a machine by issuing the following command:

        killall -SIGUSR1 mongod
        
    4. List the matching files again:

      ls /var/log/mongodb/server1.log*

      For results you get something similar to the following. The timestamps will be different.

      server1.log  server1.log.2011-11-24T23-30-00
      

      The example results indicate a log rotation performed at exactly 11:30 pm on November 24th, 2011 UTC, which is the local time offset by the local time zone. The original log file is the one with the timestamp. The new log is server1.log file.

      If you issue a second logRotate command an hour later, then an additional file would appear when listing matching files, as in the following example:

      server1.log  server1.log.2011-11-24T23-30-00  server1.log.2011-11-25T00-30-00
      

      This operation does not modify the server1.log.2011-11-24T23-30-00 file created earlier, while server1.log.2011-11-25T00-30-00 is the previous server1.log file, renamed. server1.log is a new, empty file that receives all new log output.

    python,go,redis,mongodb,.net,C#,F#,服务器架构
  • 相关阅读:
    异或加密的Python实现
    pep9课下作业
    2020-2021-1 20201319 《信息安全专业导论》第四周学习总结
    我的黑客偶像
    2020-2021-3 20201319 《信息安全专业导论》第三周学习总结
    罗马数字转阿拉伯数字
    IEEE754浮点数
    BASE64编码
    2020-2021-1 20201319 《信息安全导论》第二周学习总结
    对师生关系的想法
  • 原文地址:https://www.cnblogs.com/descusr/p/2872642.html
Copyright © 2011-2022 走看看