a. 利用sys.stdout将print行导向到你定义的日志文件中,例如: import sys # make a copy of original stdout route stdout_backup = sys.stdout # define the log file that receives your log info log_file = open("message.log", "w") # redirect print output to log fi…
1. 第一个问题:时间少了8小时 Log4j 输出的日志中,时间比系统时间少了8小时,但是 eclipse 控制台输出的日志的时间却是对的. log4j配置如下: #all logger output level is 'ERROR' and output position is stdout #so only write our project's DEBUG log and ERROR log of the others log4j.rootLogger=ERROR, stdout, R #…
最近在转移数据,sqlserver的日志文件ldf,占用空间特别大,为了还原库,节省空间,所以压缩日志文件迫在眉睫.在网上找了一段代码: USE [master] GO ALTER DATABASE AFMS SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE AFMS SET RECOVERY SIMPLE GO USE AFMS GO DBCC SHRINKFILE (N, TRUNCATEONLY) GO USE [master] GO A…
在Linux中,有时需要批量清空当前目录中的日志文件,同时还要保留日志文件. 其实一行shell命令就可以搞定,一起来看看吧. 在当前目录下,键入如下命令: for i in `find . -name "*.log"`; do cat /dev/null >$i; done for i in `find . -name "*.log"`;do >$i; done for i in `find . -name "*.log" -o -…