Owner’s Corner: Cleaning Up The Logs
We produce tons of log files that are absolutely unruly. I've attached a sample of the logs, which is only 4 days worth: sample.log How can you make any sense of that? Fortunately, we've developed a system for cleaning those up semi-automatically.
Regular Expressions (regex) are basically methods of testing string (text) patterns, with variables. You can read all about them here. For a long time, I'd actually download the log files, then one-by-one run "replace this regular expression with nothing" for each pattern inside notepad++ or gedit. How many patterns do we use in our logs? Here's the document that was our guide for a long time with all the recurring unnecessary patterns:
Spoiler Inside | SelectShow> |
---|---|
Regular Expression Commands for Cleaning Logs and Eating my Shorts by Stephen Broughton (definitely not surfrock66) (yeah right ~ Stephen Broughton) ## Explanation: If you open a log file, it’s full of junk. A program like Notepad++ for windows or gedit for linux (with the regex matching plugin) can do search and replace based on “regular expression matching” which allows search with variables. These commands strip out a lot of unnecessary shit from the logs. Simply search and replace with a blank line. ## ## Double Blank Lines ## \n\r (replace with \n) \n\n (replace with \n and do this over and over until there’s 0 matches) ## Just Timecode Lines ## ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ $ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] $ ## IP Addresses ## \[/[0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+\] ## All Severe Errors ## ## Template don’t use: ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\].*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] ebean.properties not found.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] java.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] net.minecraft.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at java.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at net.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at org.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at com.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at me.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] [\t]at sun.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] Could not pass event.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] Command [a-zA-Z0-9] failed.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] null.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] Nag author.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[WARNING\] class net.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[WARNING\] null.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Attempted to place a tile entity.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Disconnecting.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] /[0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+: Took too long to log in.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Did NOT find a new location!.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] \[dynmap\] Error writing hash file - .*$ ## Common Strippable Commands ## ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Forcing save..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Saving chunks$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Save complete.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE: Forcing save..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE: Save complete.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Enabling level saving..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Disabling level saving..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE: Disabling level saving..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE: Enabling level saving..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[CONSOLE\] Starting world backup...$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[CONSOLE\] Backup complete.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Connection reset$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Read timed out$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Connected players: .*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[CONSOLE\] Automatic restart.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[CONSOLE\] Server is restarting. World is being saved.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Stopping the server..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE: Stopping the server..$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Stopping server$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[CONSOLE->.*\] Permission denied for command.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] CONSOLE whispers Permission denied for command.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Unknown console command. Type "help" for help.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Unknown command. Type "help" for help.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] There are [0-9]+ out of a maximum 50 players online.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[WARNING\] Can't keep up! Did the system time change, or is the.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[WARNING\] Missing a prefix or suffix for.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] [Members|Retards|Noobs|Admins|Owners]+: .*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] /[0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+ lost connection$ ^[ plugin| at| craftbukkit| Entity| MinecraftServer| ThreadServerApplication| NetLoginHandler| command|java\.lang| Packet3Chat| NetworkManager]+.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Attempted to place a tile entity where there was no entity tile!$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[WARNING\] [A-Za-z0-9]+ moved too quickly!$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Adding variable - .*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] GroupManager - INFO - Data files refreshed..*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[SEVERE\] Could not pass event [a-zA-Z0-9_]+ to HeroChat.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] Playerlist for [A-Za-z0-9_]+ was not updated. Use a shorter displayname prefix.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[Essentials\] checking if [A-Za-z0-9_]+ has.*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[VNP-DEBUG\].*$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \$kills.player \$deaths.player -.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \$kills.total \$deaths.total -.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[Server\] Backing up world\(s\)$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[INFO\] \[Server\] Backup complete.$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[[A-Za-z]+\] [A-Za-z0-9]+ has left the channel$ ^[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ \[[A-Za-z]+\] [A-Za-z0-9]+ has joined the channel$ ## Weird Character Codes ## \[m$ \[[0-9]+m \[[0-9]+;[0-9]+m §[a-f0-9] |
That worked, but was quite frankly tedious. It's why it didn't get done for a long time; it took an hour or so per session. So I decided to try to automate the process with a script, and thus-far it's worked quite well. Let's call this version a "work in progress" version, since I haven't fully sorted out the edit-stop management and integration with the final stored logs.
It primarily uses the linux command sed with stdout redirection. The command "cat" prints a file, then sed will look through that print, do replacements via regex, then writes the edited output to a temporary file. Once ALL regex replaces have been made, it edits out the blank lines and pushes the changed log to the end of the existing "full server log."
The meat of this, though, is the regex commands we used. sed regex is different from Notepad++ regex, so I had to heavily modify the syntax for each regex match. Here's the script as it exists today:
**AS I UPDATE THE SCRIPT I'LL UPDATE THIS POST!
Spoiler Inside | SelectShow> |
---|---|
#!/bin/bash # # Title: script.logcleaner.sh # Description: Minecraft Log Cleaner with Regex Matching for Uneeded Lines # Author: Joseph Gullo (surfrock66) (surfrock66@surfrock66.com) # # This script prints out the entire log file to stdout in linux, then # uses sed to filter out a bunch of common log entries and replaces them # with blank text, "". It then redirects the output to a full log file. # # PARAMETERS # $1 : Input Log # $2 : Full Server Output Log # # Check that the Input Log file is really there, if not use a default if [ -z "$1" ]; then INPUT="server.log" else INPUT=$1 fi # Check that the Output Log file is really there, if not use a default if [ -z "$2" ]; then OUTPUT="full_server.log" else OUTPUT=$2 fi # Copy the log to a temporary clean file cp $INPUT server.clean.log # Replace Code: Chat Color Codes cat server.clean.log | perl -pe 's/\e\[?.*?[\@-~]//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Code Trigger with Color cat server.clean.log | sed -e 's/§[a-f0-9]//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Unknown command. Type "help" for help. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Unknown command. Type "help" for help.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Connection reset cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Connection reset$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Forcing save. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Forcing save.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Saving chunks cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Saving chunks$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Save complete. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Save complete.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE: Forcing save. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE: Forcing save.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE: Save complete. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE: Save complete.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Enabling level saving. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Enabling level saving.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Disabling level saving. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Disabling level saving.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE: Disabling level saving. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE: Disabling level saving.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE: Enabling level saving. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE: Enabling level saving.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [CONSOLE] Starting world backup. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[CONSOLE\] Starting world backup.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [CONSOLE] Server is restarting. World is being saved. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[CONSOLE\] Server is restarting. World is being saved.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Stopping the server. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Stopping the server.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE: Stopping the server. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE: Stopping the server.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Stopping server cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Stopping server$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [CONSOLE->USERNAME] Permission denied for command. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[CONSOLE->.*\] Permission denied for command.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] CONSOLE whispers Permission denied for command COMMAND cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] CONSOLE whispers Permission denied for command.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Unknown console command. Type "help" for help. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Unknown console command. Type "help" for help.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Unknown command. Type "help" for help. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Unknown command. Type "help" for help.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] There are ## out of maximum ## players online. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] There are [0-9]* out of maximum [0-9]* players online.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] PLAYERS LIST cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] [Members|Retards|Noobs|Admins|Owners]: .*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] IP lost connection cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \/[0-9]*.[0-9]*.[0-9]*.[0-9]*:[0-9]* lost connection$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Attempted to place a tile entity where there was no entity tile! cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Attempted to place a tile entity where there was no entity tile!$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Adding variable - VARIABLE cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Adding variable - .*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] GroupManager - INFO - Data files refreshed. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] GroupManager - INFO - Data files refreshed..*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Playerlist for USERNAME was not updated. Use a shorter displayname prefix. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Playerlist for [A-Za-z0-9_]* was not updated. Use a shorter displayname prefix.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [Essentials] checking if USERNAME has THIS PERMISSION cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[Essentials\] checking if [A-Za-z0-9_]* has.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [VNP-DEBUG] Debug Code cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[VNP-DEBUG\].*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] I.m sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] $kills.player $deaths.player - cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \$kills.player \$deaths.player -.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] $kills.total $deaths.player - cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \$kills.total \$deaths.total -.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [Server] Backing up world(s) cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[Server\] Backing up world\(s\)$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [Server] Backup complete. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[Server\] Backup complete.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [Server] Initiating Garbage Collection cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[Server\] Initiating Garbage Collection$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [Server] Garbage Collection complete. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[Server\] Garbage Collection complete.$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] WORLDNAME "WORLDTYPE": # chunks, # entities cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] [a-zA-Z0-9 ]* "[a-zA-Z0-9_]*": [0-9,]* chunks, [0-9,]* entities$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Uptime: # days # hours # minutes cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Uptime: [0-9]* days [0-9]* hours [0-9]* minutes$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Current TPS = # cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Current TPS = [0-9.]*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Maximum memory: # MB cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Maximum memory: [0-9,]* MB$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Allocated memory: # MB cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Allocated memory: [0-9,]* MB$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Free memory: # MB cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Free memory: [0-9,]* MB$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Attempted to place a tile entity. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Attempted to place a tile entity.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Disconnecting PLAYERNAME cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Disconnecting.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] IP: Took too long to log in. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \/[0-9]*.[0-9]*.[0-9]*.[0-9]+:[0-9]*: Took too long to log in.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] Did NOT find a new location! cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] Did NOT find a new location!.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [dynmap] Full render of maps cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[dynmap\] Full render of maps .*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [dynmap] skipping image plugins/dynmap/PATH hash match cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[dynmap\] skipping image plugins\/dynmap\/.* hash match$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [INFO] [dynmap] saving image plguins/dynmap/PATH cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] \[dynmap\] saving image plugins\/dynmap\/.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] ebean.properties not found. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] ebean.properties not found.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] java. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] java.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] net.minecraft. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] net.minecraft.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at java. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at java.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at net. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at net.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at org. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at org.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at com. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at com.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at me. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at me.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] at sun. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] at sun.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] Could not pass event cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] Could not pass event.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] Command COMMAND failed. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] Command [a-zA-Z0-9]* failed.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] null. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] null.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] Nag author. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] Nag author.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] [dynmap] Error writing hash file - cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] \[dynmap\] Error writing hash file - .*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [SEVERE] Could not pass event EVENTNAME to HeroChat. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] Could not pass event [a-zA-Z0-9_]* to HeroChat.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] class net. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] class net.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] null. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] null.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] Can't keep up! Did the system time change, or is the system overloaded? cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] Can.t keep up! Did the system time change, or is the.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] Missing a prefix or suffix for cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] Missing a prefix or suffix for.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] PLAYERNAME moved too quickly! cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] [A-Za-z0-9_]* moved too quickly!$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [WARNING] PLAYERNAME moved wrongly! cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] [A-Za-z0-9_]* moved wrongly!$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [Username] has left the channel. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[[A-Za-z]*\] [A-Za-z0-9]* has left the channel$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: ####-##-#### ##:##:## [Username] has joined the channel. cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[[A-Za-z]*\] [A-Za-z0-9]* has joined the channel$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java Errors cat server.clean.log | sed -e 's/^[ plugin| at| craftbukkit| Entity| MinecraftServer| ThreadServerApplication| NetLoginHandler| command|java\.lang| Packet3Chat| NetworkManager]+.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: IP Addresses cat server.clean.log | sed -e 's/\[\/[0-9]*.[0-9]*.[0-9]*.[0-9]*:[0-9]*\]//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Blank Timecode Lines cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* $//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Blank Timecode Lines With [INFO] tags cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] $//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " at java." cat server.clean.log | sed -e 's/^ at java.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " at net." cat server.clean.log | sed -e 's/^ at net.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " at org." cat server.clean.log | sed -e 's/^ at org.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " at com." cat server.clean.log | sed -e 's/^ at com.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " me." cat server.clean.log | sed -e 's/^ at me.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java tracer errors starting with " at sun." cat server.clean.log | sed -e 's/^ at sun.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java errors starting with java. cat server.clean.log | sed -e 's/^java.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java errors starting with org. cat server.clean.log | sed -e 's/^org.*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Repeat lines from java errors, in the form " ... # more" cat server.clean.log | sed -e 's/^ \.\.\. [0-9]* more*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Replace Code: Java error source tracking cat server.clean.log | sed -e 's/^Caused by: .*$//g' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Delete Blank Lines cat server.clean.log | sed '/^$/d' > server.clean.log.tmp mv server.clean.log.tmp server.clean.log # Push the clean output to the full server file cat server.clean.log >> $OUTPUT # Remove the temporary log file rm server.clean.log #Info Template #cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[INFO\] $//g' > server.clean.log.tmp #Severe Template #cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[SEVERE\] $//g' > server.clean.log.tmp #Warning Template #cat server.clean.log | sed -e 's/^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]* \[WARNING\] $//g' > server.clean.log.tmp |
The end result is a nice, pretty, clean log file which we can store: sample.clean.log I still need to replace the code in the backup script that directs the logs to the full file to call this instead, and then I need to comment this monster because it's unruly.
This entry was posted on Friday, October 12th, 2012 at 8:27 pm by surfrock66 and is filed under Owner's Corner.
You can leave a response, or trackback from your own site.
One Response to “Owner’s Corner: Cleaning Up The Logs”
i looked at the sample log, and did ctrl + f, and typed in iKips, 1 out of 953 :D
and surf, you work pretty damn hard on this server to make things run smoothly. a big thank you from me.