1. Hi there Guest! You should join our Minecraft server @ meepcraft.com
  2. We also have a Discord server that you can join @ https://discord.gg/B4shfCZjYx
  3. Purchase a rank upgrade and get it instantly in-game! Minecraft Discord Upgrade

How to Search Your Minecraft Chat Logs

Discussion in 'Unofficial Guides' started by NuckleMuckle, Dec 5, 2015.

  1. NuckleMuckle

    NuckleMuckle Popular Meeper

    Offline
    Messages:
    358
    Likes Received:
    431
    If you're running Minecraft on a Linux machine, this isn't for you, as you're already awesome, and you don't need any help. If you're using a Mac/tablet/whatever, I can't help you, as I don't play with those. This is specifically for Windows users, who frankly need all the technical help they can get.

    Ever wanted to answer the burning questions?

    - When was the last time I beat City parkour?
    - What was the name of that town I visited yesterday with that cool structure?
    - Did anyone mention me in Global while I was afk?
    - I sold a ton of stuff yesterday at chest shops. How much did I make?

    Here's how to answer those:

    Minecraft stores your logs in your Windows user folder, usually here: C:\Users\<username>\AppData\Roaming\.minecraft\logs. If you look at the folder, there will be one plain-text file called latest.log. That file will open in any text editor of your choice, like Notepad, and is searchable in the normal ways.

    Whenever you restart Minecraft, it creates a new latest.log by first archiving the one that was already there. It uses the Linux utility gzip to compress the text file, and allocates it with a filename that includes the date that that particular Minecraft log began, with a -1 after it in case you do it more than once a day, so you get -2, -3, etc, like this:

    Typically, once a file has been compressed, the only way to read it is to uncompress it. It's still possible on a Windows machine to search through .zip files, but that's not what Minecraft uses. So, what to do to look at those archive logs?

    If Minecraft is using a Linux utility to archive them, then it only makes sense to use a Linux utility to read them. Here's what to do:

    Initial Setup

    1) Download and install Cygwin: https://www.cygwin.com/

    This is a very simple program that allows you to run Linux utilities on a Windows machine.

    2) Launch Cygwin.

    3) Create a symbolic link to your Minecraft logs directory, because that's a really long string you don't want to be typing with all the time:

    This creates a path called mclogs that takes you directly to your Minecraft logs directory just by typing: cd mclogs

    4) Change directory: cd mclogs

    5) List the contents of the directory: ls

    If you see the same list of files you can see in Windows explorer, you've done everything right up to this point.

    Now you're finished with setup, and ready to run queries. Linux supplies (and Cygwin provides) the utility zgrep to search for character matches in a gzip archive, and print the results. Those results can be searched even more with the normal Linux search utility grep, and you can use a pipe (|) to pass the output of one command directly to another without bothering you in between.

    All the syntax you'll need for the two commands is:

    zgrep <string to match> <filename>
    grep <string to match>

    And you need to know what you're looking for.

    Example

    So, for example, I want to know when, in the last week, I beat any parkour level, so I can figure out when my 7 days are up and I can beat it again. I'm pretty sure I beat them all since the first of the month, so I can limit my search to logs with a December date, which will save me some time. If I look at global chat, I can see an example of what the message looks like:

    It's important to notice where the line break is, because zgrep and grep will only return matching lines, so If I try to search for "finished" and "City" and "28000", I won't get any matches, they're not on the same line. It's also important to keep in mind that in Linux everything is case-sensitive, so "City" will return matches but "city" will not. And finally, this isn't like Google, where you can put all your keywords in wherever. This is why we'll need multiple commands, in order to search on keywords that aren't next to each other (and thus not in a contiguous string).

    So in this case, I've decided to search for "(MeepCraft)", which limits my results to server messages, and only on those with a date of December:

    A bit of explanation - the characters "(" and ")" have special meaning in Linux, but I don't want them to be recognized as special in this case, I want the search to treat them just like ordinary characters. I therefore must "escape" them, in Linux parlance, by putting an escape character in front of each of them: \

    The filename can be wild-carded with *, so it'll search for any filename in the directory beginning with 2015-12.

    The results from that show every single server message, though, and I only want mine. So I can further refine that by piping the first command into a grep for my name:

    That's tons better, but I still have one more problem: it's mixing in all my votes, too. I just want parkour times.

    Oh yeah, that's MUCH better:

    I now know the exact time I beat Balloon (Doh! That's up too late for a school night!) The date may or may not be 100% accurate, though; remember, the date on the filename is the day the log file started, so it's possible I started this log on 12/1 and finished Balloon after midnight on 12/2 - an important distinction in this case! But here I can look at my list of filenames and see I have a -1, -2, and -3 for 12/1, this was found in the middle, so it must have been on that date. Problem solved.

    There ya go!
     
    Last edited: Dec 8, 2015
  2. CrazyYoungBro

    CrazyYoungBro Popular Meeper

    Offline
    Messages:
    506
    Likes Received:
    836
    Well Done
     

Share This Page