将apache日志按年月日目录分类存放,便于日志分析系统分析。使用cronolog来完成,有windows和linux的版本。Linux安装,解压缩后执行
#./configure
#./make
#./make install
在httpd.conf配置使用cronolog,在每个虚拟主机中,加入
CustomLog "|/usr/local/sbin/cronolog /var/logs/%Y/%m/%Y%m%d_access.log" combined
ErrorLog "|/usr/local/sbin/cronolog /var/logs/%Y/%m/%Y%m%d_error.log"
Windows下cronolog安装,解压缩后,将cronolog.exe文件放到apache安装目录的bin下。配置httpd.conf
TransferLog "|D:/Apache/bin/cronolog.exe D:/Apache/logs/%Y/%m/%d/access.log"
ErrorLog "|D:/Apache/bin/cronolog.exe D:/Apache/logs/%Y/%m/%d/access.log"
说明:数据表fawen是文件的标题,正文等信息,数据表pishi是各领导对文件的批示信息,pishi的articleid字段内容与fawen的id相关联。要统计出某位领导的所有批示,导出EXCEL,内容是:文件名称、批示内容、批示时间。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
| <?php
$DB_Server = "localhost";
$DB_Username = "root";
$DB_Password = "pass";
$DB_DBName = "office";
$DB_TBLName = "fawen";
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
or die("Couldn't connect.");
$Db = @mysql_select_db($DB_DBName, $Connect)
or die("Couldn't select database.");
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=mydowns.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
$now_date = date('Y-m-d H:i');
$title = "格式:第一列为文件名,第二列为领导批示内容,第三列为批示日期";
$sql = "Select $DB_TBLName.title,pishi.content,pishi.time from $DB_TBLName,pishi where pishi.leadername='领导名称' and $DB_TBLName.id=pishi.articleid";
$ALT_Db = @mysql_select_db($DB_DBName, $Connect)
or die("Couldn't select database");
$result = @mysql_query($sql,$Connect)
or die(mysql_error());
$result2 = @mysql_query($sql2,$Connect)
or die(mysql_error());
echo("$titlen");
$sep = "t";
//for ($i = 0; $i < mysql_num_fields($result); $i++) {
//echo mysql_field_name($result,$i) . "n";
//}
print("nnn");
$i = 0;
while($row = mysql_fetch_row($result))
{
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert .= "t";
print(trim($schema_insert));
print "nnnn";
$i++;
}
return (true);
?> |
最新评论