开发者

How do I stop Apache from inserting unwanted line breaks in its error log?

开发者 https://www.devze.com 2023-01-16 11:35 出处:网络
My Perl/FastCGI app makes extensive use of \"print STDERR\" to log all sorts of debugging info to the Apache error log file.

My Perl/FastCGI app makes extensive use of "print STDERR" to log all sorts of debugging info to the Apache error log file.

I insert frequent line breaks myself, but Apache (or perhaps FastCGI?) still feels the need to insert extra line breaks, usually right in the middle of my nicely formatted output.

How can I stop this from happening?

Here is an example:

[Sun Sep 19 12:51:49 2010] [warn] mod_fcgid: stderr: request OK: client / index :0.035902 wallclock secs ( 0.030 usr  0.开发者_如何学Python000 sys +  0.000 cusr  0.000 csys =  0.030 CPU)
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: REQUEST pid:3569   ctr:4   time: 15   path:/client/index
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: REQUEST: /client/index   log: 9473
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 1--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 2--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 3--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 4--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 5--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 6--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 7--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 8--45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 9--4
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 5678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 10-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 11-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 12-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 13-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 14-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 15-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 16-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 17-45678901234567890123456789012345678901234567890
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 18-4567890123456789012345678901234567890123456789
[Sun Sep 19 12:51:52 2010] [warn] mod_fcgid: stderr: 0

Each line should contain 51 characters, including a \n, and not counting apache's preamble. Each line is output in it's own print() call, so it's not a consequence of dumping a lot of text at once.

It seems to happen every 504 characters, starting from the beginning of each FastCGI request. If I have a bunch of requests in a row that print very little info, I never see the line break.


Why don't use just use Log4Perl instead?

Can you give some examples of the unwanted line breaks? Are you sure the error log really has extra line breaks or is something else, such as your terminal, wrapping them?

This sounds suspiciously like buffered output. What happens if you unbuffer STDERR?

 {
 my $old = select(STDERR);
 $|++;
 select( $old );
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消