thinkphp关闭日志记录

没怎么去研究tp的框架底层,虽然说有个静态成员public static $debug = true;来设置调试,但后来发现根本不是

不知道TP框架开发者就不能考虑考虑如果是不懂框架只懂用接口的可要怎么让网站长时间生存,别人一个AB命令过来不得日志好几个G?

框架就不研究了,浪费时间,其实大概看了一下,有一通用调用LOG的地方

文件位置:

站点根目录/thinkphp/library/think/log/driver/File.php

/**
* 日志写入接口
* @access public
* @param array $log 日志信息
* @param bool $depr 是否写入分割线
* @return bool
*/
public function save(array $log = [], $depr = true)
{
return false; //直接取消日志写入,干脆明了
$now = date($this->config[‘time_format’]);
$destination = $this->config[‘path’] . date(‘Ym’) . DS . date(‘d’) . ‘.log’;

$path = dirname($destination);
!is_dir($path) && mkdir($path, 0755, true);

//检测日志文件大小,超过配置大小则备份日志文件重新生成
if (is_file($destination) && floor($this->config[‘file_size’]) <= filesize($destination)) {
rename($destination, dirname($destination) . DS . $_SERVER[‘REQUEST_TIME’] . ‘-‘ . basename($destination));
}

$depr = $depr ? “—————————————————————\r\n” : ”;
$info = ”;
if (App::$debug) {
// 获取基本信息
if (isset($_SERVER[‘HTTP_HOST’])) {
$current_uri = $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
} else {
$current_uri = “cmd:” . implode(‘ ‘, $_SERVER[‘argv’]);
}

$runtime = round(microtime(true) – THINK_START_TIME, 10);
$reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : ‘∞’;
$time_str = ‘ [运行时间:’ . number_format($runtime, 6) . ‘s][吞吐率:’ . $reqs . ‘req/s]’;
$memory_use = number_format((memory_get_usage() – THINK_START_MEM) / 1024, 2);
$memory_str = ‘ [内存消耗:’ . $memory_use . ‘kb]’;
$file_load = ‘ [文件加载:’ . count(get_included_files()) . ‘]’;

$info = ‘[ log ] ‘ . $current_uri . $time_str . $memory_str . $file_load . “\r\n”;
$server = isset($_SERVER[‘SERVER_ADDR’]) ? $_SERVER[‘SERVER_ADDR’] : ‘0.0.0.0’;
$remote = isset($_SERVER[‘REMOTE_ADDR’]) ? $_SERVER[‘REMOTE_ADDR’] : ‘0.0.0.0’;
$method = isset($_SERVER[‘REQUEST_METHOD’]) ? $_SERVER[‘REQUEST_METHOD’] : ‘CLI’;
$uri = isset($_SERVER[‘REQUEST_URI’]) ? $_SERVER[‘REQUEST_URI’] : ”;
}
foreach ($log as $type => $val) {
$level = ”;
foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
$level .= ‘[ ‘ . $type . ‘ ] ‘ . $msg . “\r\n”;
}
if (in_array($type, $this->config[‘apart_level’])) {
// 独立记录的日志级别
$filename = $path . DS . date(‘d’) . ‘_’ . $type . ‘.log’;
error_log(“[{$now}] {$level}\r\n{$depr}”, 3, $filename);
} else {
$info .= $level;
}
}
if (App::$debug) {
$info = “{$server} {$remote} {$method} {$uri}\r\n” . $info;
}
return error_log(“[{$now}] {$info}\r\n{$depr}”, 3, $destination);
}

 

在public function save()方法里直接一个return false; 问题搞定!

《thinkphp关闭日志记录》上有109条评论

  1. Today, I went to the beach front with my children. I found a sea shell and gave
    it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her
    ear. She never wants to go back! LoL I know this is
    entirely off topic but I had to tell someone!

  2. Very nice post. I just stumbled upon your weblog and wanted
    to say that I’ve really enjoyed browsing your blog posts.
    In any case I’ll be subscribing to your rss feed and I hope you
    write again very soon!

  3. With havin so much content do you ever run into any problems of plagorism or copyright violation? My website has a
    lot of exclusive content I’ve either created
    myself or outsourced but it appears a lot of it is popping it up all
    over the internet without my agreement. Do you know any solutions to help prevent content from being stolen? I’d certainly appreciate it.

  4. I’m not that much of a internet reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back in the future.
    All the best

  5. Please let me know if you’re looking for a article writer for your weblog.
    You have some really good posts and I believe I would be a good asset.
    If you ever want to take some of the load off,
    I’d really like to write some content for your blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Many thanks!

  6. Hi, i feel that i noticed you visited my web site so i came to go back the desire?.I
    am attempting to find things to improve my site!I suppose
    its ok to make use of a few of your ideas!!

  7. Does your website have a contact page? I’m having
    trouble locating it but, I’d like to send you an email.

    I’ve ggot some ideas for your blog you might be interested in hearing.
    Either way, great website and I look forward to seeing it grow over time.

  8. Hi! I’ve been following your site for some time now and finally got the courage to go ahead and
    give you a shout out from Atascocita Texas!
    Just wanted to say keep up the excellent work! Is it OK to post on Pinterest?
    Keep up the fantastic work!

  9. Excellent post. I was checking constantly this
    weblog and I am inspired! Extremely useful information particularly the remaining section 🙂 I deal with such info
    much. I was looking for this particular info for a very
    long time. Thank you and best of luck.

  10. It’s a shame you don’t have a donate button! I’d without a doubt donate to this excellent blog!
    I guess for now i’ll settle for book-marking and adding
    your RSS feed to my Google account. I look forward to fresh updates and will share this
    blog with my Facebook group. Talk soon!

  11. Hello, i think that i saw you visited my weblog thus i came to return the choose?.I
    am attempting to in finding things to enhance my website!I guess its good enough to make use of a few of your ideas!!

  12. The games are extremely all to easy to play you could find the
    more interesting games you wish to play. Online sportsbook sites have come further due to the advances of bookie software this offer sports bettors in game or live wagering options because the games have been in progress.

    The program of these sites are actually created by mainly several
    specialist developers plus they all considered as someone you with as enjoyable and realistic a
    conference as is possible that you can play casino
    poker online.

  13. Woah! I’m really digging the template/theme of
    this site. It’s simple, yet effective. A lot of times it’s tough to get that
    “perfect balance” between usability and visual appearance.

    I must say that you’ve done a excellent job with
    this. Additionally, the blog loads extremely fast for me
    on Opera. Superb Blog!

  14. Hello there, just became aware of your blog through Google, and found that it is really informative.

    I am gonna watch out for brussels. I’ll be grateful if you continue this in future.
    Lots of people will be benefited from your writing.

    Cheers!

  15. Howdy I am so excited I found your weblog, I really found you by error, while
    I was looking on Google for something else, Nonetheless I am here now and would
    just like to say thanks a lot for a marvelous
    post and a all round thrilling blog (I also love the theme/design), I don’t have time to
    read through it all at the moment but I have book-marked it and
    also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the great
    work.

  16. What i don’t realize is in truth how you are not actually much more well-favored than you
    might be now. You are very intelligent. You already know therefore significantly
    in terms of this topic, produced me in my opinion imagine it from
    a lot of varied angles. Its like women and men are not
    interested except it’s one thing to do with Lady gaga!
    Your individual stuffs great. At all times take
    care of it up!

  17. Howdy just wanted to give you a quick heads up. The words in your post seem to be running off
    the screen in Internet explorer. I’m not sure if
    this is a formatting issue or something to do with web browser
    compatibility but I thought I’d post to let you know. The style and
    design look great though! Hope you get the issue solved soon. Cheers

  18. MarioQQ is a site of authentic loan to play poker online with
    the most effective high quality web servers in addition to the most up to
    date appearance.Only in MarioQQ online poker firm that offers
    guarantees of safety in online play casino poker without the admin crawler,
    as well as we always provide the most effective service 24 hr a day, now all members can play poker anytime as well as anywhere
    due to the fact that we Android as well as Iphone application giving so you can play
    MarioQQ on your smart device.

  19. is a relied on QQ Online poker Online and Bandar Ceme
    Online gambling site that supplies on the internet card games such as Online Texas Hold’em, DominoQQ, Capsa Online, Ceme Online, Ceme99, Online Gambling Online Online Poker
    Sites. QQ Poker Ceme, the best as well as safest on-line texas hold’em representative site
    with 24 hr IDN Online Poker service. For those of you Lovers of the video
    game Online Online as well as that want to play betting Online Poker, Online Ceme, Domino QQ, City Ceme, Online Betting, Bandar Capsa Online in 1 ID

  20. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several e-mails with
    the same comment. Is there any way you can remove me from that
    service? Thank you!

  21. I’m extremely impressed with your writing skills and also with
    the layout on your weblog. Is this a paid theme
    or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a nice blog like this one nowadays.

  22. is a trusted QQ Casino poker Online and Bandar Ceme Online gambling site that offers online card games such as Online Texas Hold’em, DominoQQ, Capsa
    Online, Ceme Online, Ceme99, Online Gambling Online Casino Poker Sites.
    QQ Casino Poker Ceme, the most effective and safest on-line casino poker agent
    site with 24 hr IDN Online Texas hold’em solution. For those of you Lovers
    of the video game Online Online as well as that want to play
    gambling Online Online poker, Online Ceme, Domino QQ, City Ceme,
    Online Gambling, Bandar Capsa Online in 1 ID

  23. This design is spectacular! You definitely know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well,
    almost…HaHa!) Excellent job. I really loved what you had to say, and more
    than that, how you presented it. Too cool!

  24. My spouse and I stumbled over here different web address and thought I may as well check things out.
    I like what I see so now i am following you.
    Look forward to exploring your web page repeatedly.

  25. is a relied on QQ Texas hold’em Online as well as Bandar Ceme Online betting site that
    provides on the internet card games such as Online Online Poker, DominoQQ,
    Capsa Online, Ceme Online, Ceme99, Online Betting Online
    Casino Poker Sites. QQ Poker Ceme, the most effective and
    safest on the internet casino poker representative website with 24-hour IDN Online Casino poker service.
    For those of you Lovers of the game Online Online as well as who intend to play betting Online Poker, Online Ceme,
    Domino QQ, City Ceme, Online Gambling, Bandar Capsa Online in 1 ID

  26. Howdy would you mind sharing which blog platform you’re using?
    I’m going to start my own blog soon but I’m having a tough time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs
    and I’m looking for something unique.
    P.S Sorry for getting off-topic but I had to ask!
    Also, Is it OK to post on Pinterest? Keep up the great work!

  27. is a trusted QQ Casino poker Online as well as Bandar Ceme Online
    betting website that provides online card video games such as
    Online Casino Poker, DominoQQ, Capsa Online, Ceme Online, Ceme99,
    Online Gambling Online Poker Sites. QQ Online Poker Ceme, the
    best as well as most safe on the internet texas hold’em agent website with 24-hour IDN Online
    Texas hold’em service. For those of you Lovers of the game
    Online Online and who want to play betting Online Casino poker,
    Online Ceme, Domino QQ, City Ceme, Online Betting, Bandar Capsa Online in 1 ID

  28. Hello! This is kind of off topic but I need some
    guidance from an established blog. Is it hard to set up your
    own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about setting up my own but I’m not sure where to start.

    Do you have any tips or suggestions? With thanks

  29. I think this is one of the such a lot significant information for me.
    And i am satisfied studying your article.
    However wanna statement on some common things, The site taste is ideal, the articles is truly excellent : D.

    Excellent job, cheers

  30. is a trusted QQ Casino poker Online and Bandar Ceme
    Online betting site that provides online card video games such
    as Online Online Poker, DominoQQ, Capsa Online, Ceme Online,
    Ceme99, Online Betting Online Poker Sites. QQ Online Poker Ceme, the best and best
    online texas hold’em agent site with 24 hr IDN Online Casino poker solution. For
    those of you Lovers of the game Online Online and also who intend to play wagering Online Texas hold’em, Online
    Ceme, Domino QQ, City Ceme, Online Betting, Bandar
    Capsa Online in 1 ID

  31. We are a group of volunteers and opening a brand new
    scheme in our community. Your website offered us with
    useful info to work on. You’ve performed a formidable process and our whole neighborhood will likely
    be thankful to you.

  32. is a relied on QQ Texas hold’em Online as well
    as Bandar Ceme Online betting website that provides on the internet card video games such as Online
    Poker, DominoQQ, Capsa Online, Ceme Online, Ceme99, Online Gambling Online Online Poker Sites.
    QQ Casino Poker Ceme, the very best and also best on the
    internet casino poker representative website with 24 hour IDN Online Texas
    hold’em solution. For those of you Lovers of the game Online Online and also who wish to
    play gambling Online Texas hold’em, Online Ceme, Domino QQ, City Ceme, Online Betting,
    Bandar Capsa Online in 1 ID

  33. Its such as you read my thoughts! You seem to understand so much
    approximately this, such as you wrote the e-book in it or
    something. I feel that you can do with a few % to force the
    message house a bit, but instead of that, this is excellent blog.
    An excellent read. I will certainly be back.

  34. I have been browsing online greater than 3 hours as of
    late, but I by no means discovered any fascinating article like yours.
    It’s lovely price sufficient for me. Personally, if all
    web owners and bloggers made just right content material as you did, the internet shall be a lot more helpful than ever before.

  35. I’m really impressed with your writing skills as well as with the layout
    on your weblog. Is this a paid theme or did you modify it yourself?
    Either way keep up the excellent quality writing, it’s rare to see
    a nice blog like this one these days.

  36. I like the helpful info you provide in your articles.
    I will bookmark your weblog and check again here regularly.

    I’m quite sure I will learn lots of new stuff right here!
    Good luck for the next!

  37. Superb website you have here but I was wondering if you knew of any
    forums that cover the same topics discussed here? I’d really like to be
    a part of group where I can get comments from
    other knowledgeable people that share the same interest. If
    you have any suggestions, please let me know.

    Thanks!

  38. Does your site have a contact page? I’m having problems locating it
    but, I’d like to shoot you an email. I’ve got some recommendations for your
    blog you might be interested in hearing. Either way, great blog and I look forward to seeing it develop over time.

  39. Have you ever considered writing an e-book or guest authoring on other
    websites? I have a blog based on the same subjects you discuss and would really like tto have you share some stories/information. I know my readers would value your work.
    If you’re even remotely interested, feel free to send me an e-mail.

  40. I seriously love your blog.. Pleasant colors & theme. Did you develop this web site yourself?

    Please reply back as I’m hoping to create my very own website
    and want to find out where you got this from or just what the theme is named.
    Appreciate it!

  41. Hello there, just became aware of your blog through Google, and found that
    it is truly informative. I am going to watch out for brussels.
    I’ll appreciate if you continue this in future. Many people will be benefited from your writing.
    Cheers!

  42. Aviation training in order to hone your talent is better learned
    on the flight simulator console on your own PC by using a few
    clicks of your mouse plus a joystick. But even though
    you may pick the right games, you have to check the period of time
    you would spend on them. Nintendo DS, also abbreviated as NDS is really a
    hand-held video gaming console.

  43. I just couldn’t go away your site before suggesting that I really loved the usual info an individual provide to your guests?
    Is gonna be again regularly to check up on new posts

  44. Hello I am so excited I found your web site, I
    really found you by error, while I was researching on Yahoo for something else, Nonetheless I
    am here now and would just like to say cheers for a tremendous post and a all round enjoyable blog (I also love the theme/design), I don’t have time to look over it
    all at the moment but I have saved it and also added your
    RSS feeds, so when I have time I will be back to read a great
    deal more, Please do keep up the fantastic work.

  45. Nice post. I was checking continuously this blog
    and I am inspired! Extremely useful information particularly the last
    phase 🙂 I handle such information a lot. I used to be looking for this certain info for a very lengthy time.
    Thanks and best of luck.

  46. I got this site from my buddy who informed me about this website and now
    this time I am browsing this website and reading very informative articles here.

  47. Hello There. I discovered your weblog the use of msn. That is an extremely smartly written article.
    I’ll be sure to bookmark it and come back to learn extra of your helpful info.
    Thank you for the post. I will certainly comeback.

  48. Howdy this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code
    with HTML. I’m starting a blog soon but have no coding expertise so I wanted to get advice from someone with experience.
    Any help would be greatly appreciated!

  49. Howdy! I could have sworn I’ve visited this site before but after browsing through many of the articles I realized it’s new to me.
    Anyhow, I’m definitely delighted I stumbled upon it and I’ll be book-marking it and checking back often!

发表评论

电子邮件地址不会被公开。 必填项已用*标注