This Windows system tray application stops e.g. the Apache webserver, archives the log files and restarts the webserver on a pedefined schedule.
RotateLogs uses 7Zip to compress the logs. 7-Zip is licensed under the GNU LGPL license. More info can be found at www.7-zip.org. |
|
- | Tested on Apache webserver |
- | Schedule can be set to daily, weekly or monthly |
- | Compresses the old logfiles using 7za.exe (included) |
- | Starts and stops the webserver services (with a predefined commandline) |
- | Optionally writes a logfile with executed tasks |
|
|
At home I have a Windows server running Apache v2.x HTTPD. On this server DULMEN.net is hosted. As most server applications Apache HTTPD logs all data requests and errors in log files. These log files keep growing until they are manually cleared or removed. I always forget this kind of simple tasks and after removing a log file of more than 25Gb I decided to automate this task.
RotateLogs automatically stops the Apache HTTPD service, renames the log files by adding the date in front of the filename, archives the log files into a compressed file using the commandline version of 7Zip (included) and restarts the Apache HTTPD service. All this following a predefined schedule or manually from the Windows system tray menu.
The first time RotateLogs is started it elevates itself by registering with the highest privileges. The Windows User Account Control (UAC) will prompt for confirmation. As long as it is started from the same folder this confirmation is not needed after the first run.
If an error occures during the rotation of the Apache log files the icon in the system tray is changed (red circle with x is added to the icon). Errors are loged in the RotateLogs log file which can be opened from the main window or the system tray menu. See the error codes below.
If all went well a green circle with a check mark is added to the system tray icon.
The configuration file can also be opened from the main window or the system tray menu. After editing the configuration file Refresh needs to be choosen from the system tray menu to activate the new settings.
|
|
|
RotateLogs log file, main window and tray menu |
|
|
RotateLogs.exe Error codes |
101 | Unable to stop service |
102 | Unable to start service |
103 | No log files found matching the specifications |
104 | Compressed file not found after creation |
201 | Error executing server stop command |
202 | Error executing server start command |
|
7za.exe Errorlevel codes |
0 | Success: Successful operation |
1 | Warning: Non fatal error(s) occurred |
2 | FatalError: A fatal error occurred |
3 | CRCError: A CRC error occurred when unpacking |
4 | LockedArchive: Attempt to modify an archive previously locked |
5 | WriteError: Write to disk error |
6 | OpenError: Open file error |
7 | UserError: Command line option error |
8 | MemoryError: Not enough memory for operation |
9 | CreateFileError: Create file error |
255 | UserBreak: User stopped the process |
Error | Error executing compression command (generated by AHK) |
|
|
No command-line options available. |
|
[ApplicationOptions] |
|
Writelog |
Create application log (1=On, 0=Off, Default=On) |
MaxLogSizeKb |
Max log file size in Kb(Default=100) |
[ServerOptions] |
|
ServerName |
Server name (Default=Apache) |
ServerProgram |
Server application (Default=C:\SERVER\Apache2.2\bin\httpd.exe) |
ServiceName |
Service name (Default=Apache2.2) |
ServerStopCmd |
Service stop command parameters (Default= -w -n "Apache2.2" -k stop) |
ServerStartCmd |
Service start command parameters (Default= -w -n "Apache2.2" -k start) |
[LogOptions] |
|
ServerLogsDir |
Server log files directory (Default=C:\SERVER\Apache2.2\Logs) |
LogsDestinationDir |
Log files destination directory Default=C:\SERVER\Apache2.2\Logs) |
AccessLogName |
String in filename access log (Default=Access) |
ErrorLogName |
String in filename error log (Default=Error) |
[TimerOptions] |
|
DailyWeeklyMonthly |
Rotate frequency (D=Daily, W=Weekly, M=Monthly, Default=M) |
DayNumber |
Day of week (1=Sun..7=Sat) OR Day of month (01..31, Default=01) |
HourNumber |
Hour of day (00..23, Default=02) |
|
|
|
|
v1.0 |
Initial setup |
v1.1 |
Added administrator rights request on startup (only once) |
|
|
No known bugs.
|
|
None.
|
|
Please read the legal notice first, allthough you probably heard it before :)
Copyright 2018 DULMEN.net. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY DULMEN.net ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL DULMEN.net OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and
should not be interpreted as representing official policies, either expressed or implied, of DULMEN.net.
|
You can download RotateLogs as a compressed folder containing all files needed. No need to install the software, just unzip, adapt the configuration file RotateLogs.ini and run RotateLogs.exe.
RotateLogs is free for personal and bussiness use and is free to distribute as is as long as the program is not altered and accompanied with the RotateLogs text file.
|
|