Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4381890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:42:28+00:00 2026-05-21T12:42:28+00:00

I’ve got a huge log file (almost 6 GB) of a game server filled

  • 0

I’ve got a huge log file (almost 6 GB) of a game server filled with millions of errors (hundreds were caused every second at that time) besides useful records that need to be kept. I’d like to remove all the lines including an error while keeping the ones showing chat messages or other information.

However, I can’t just easily remove the lines I’d like to dump because the error messages aren’t always the same and always require a different amount of lines. In short, I simply can’t determine which lines include an error. I need a regular expression to do so. I’ve been looking for a program that fits my purposes. I haven’t found one yet, though. sed (stream editor) could do such a job for instance as it wouldn’t need too many resources to process such a huge file. However, it doesn’t support finding and replacing over multiple lines.

Therefore, is there a program that supports finding and replacing regular expressions in huge text files over multiple lines? Or is it recommended to write your own script to do that job?

The log file looks as follows:

2011-03-02 01:43:00 [INFO] <admin> CraftBook is causing errors. 
2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z
    at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174)
    at net.minecraft.server.BlockButton.a(BlockButton.java:170)
    at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:160)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:482)
    at net.minecraft.server.Packet15Place.a(SourceFile:57)
    at net.minecraft.server.NetworkManager.a(SourceFile:230)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:75)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
2011-03-02 01:43:01 [INFO] <admin> Is it working yet? 
2011-03-02 01:43:01 [INFO] <admin> Not really. 
2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z
    at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
2011-03-02 01:43:02 [INFO] <admin> I hope we find a solution as soon as ever possible. 

The desired result would be the following:

2011-03-02 01:43:00 [INFO] <admin> CraftBook is causing errors.
2011-03-02 01:43:01 [INFO] <admin> Is it working yet? 
2011-03-02 01:43:01 [INFO] <admin> Not really. 
2011-03-02 01:43:02 [INFO] <admin> I hope we find a solution as soon as ever possible.

As you can see, the log file contains the same error over and over again. Even though it always starts with the date and time followed by [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms and ends with at net.minecraft.server.ThreadServerApplication.run(SourceFile:366), the error message in between is different each time. That’s why I can’t just replace the error message by an empty string.

Is there a regular expression that could both help me get rid of all the lines containing an error but keep the remaining lines? That way, my log file would shrink to under 50 MB in size as it used to be before all these errors were caused by my server due to a broken plugin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:42:29+00:00Added an answer on May 21, 2026 at 12:42 pm

    This Python script makes one pass through a logfile read from stdin, printing the filtered log messages to stdout.

    It uses a regular expression to match lines that mark the beginning of a log message (such as a line that starts with 2011-03-02 01:43:00 [).

    If a line that begins a log message contains [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms, the script discards all lines between that line and the line containing the start of the next log message. Otherwise, it outputs the line. You can think of this as a finite state machine with two states, which correspond to whether the script is skipping over lines or outputting lines.

    import sys
    import re
    
    START_OF_MESSAGE_RE = r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"
    ERROR_RE = START_OF_MESSAGE_RE + r' \[SEVERE\] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms$'
    skip_until_next_message = False
    
    for line in sys.stdin:
        line = line.rstrip()
        if re.match(START_OF_MESSAGE_RE, line):
            if re.match(ERROR_RE, line):
                skip_until_next_message = True
            else:
                skip_until_next_message = False
        if not skip_until_next_message:
            print line
    

    I added some special cases to the log file for testing. Here’s the log file that I tested it with:

    2011-03-02 01:43:00 [INFO] <admin> CraftBook is causing errors. 
    2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
    java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z
        at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174)
        at net.minecraft.server.BlockButton.a(BlockButton.java:170)
        at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:160)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:482)
        at net.minecraft.server.Packet15Place.a(SourceFile:57)
        at net.minecraft.server.NetworkManager.a(SourceFile:230)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:75)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
        [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    2011-03-02 01:43:01 [INFO] <admin> Is it working yet? 
    2011-03-02 01:43:01 [INFO] <admin> Not really. 
    2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
    java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z
        at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    2011-03-02 01:43:02 [INFO] <admin> I hope we find a solution as soon as ever possible. 
    2011-03-02 01:43:01 [SEVERE] Another multi
    line
    log
    message
    2011-03-02 01:43:01 [INFO] <admin> Here's the error: [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
    

    And here’s the output:

    $ python minecraftlog.py < minecraft.log 
    2011-03-02 01:43:00 [INFO] <admin> CraftBook is causing errors.
    2011-03-02 01:43:01 [INFO] <admin> Is it working yet?
    2011-03-02 01:43:01 [INFO] <admin> Not really.
    2011-03-02 01:43:02 [INFO] <admin> I hope we find a solution as soon as ever possible.
    2011-03-02 01:43:01 [SEVERE] Another multi
    line
    log
    message
    2011-03-02 01:43:01 [INFO] <admin> Here's the error: [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.