Log file format (log4j2)

Discussion in 'Bukkit Discussion' started by Bobcat00, Dec 21, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Bobcat00

    I used to use the options --log-limit 524288 and --log-count 10 with Craftbukkit, which would give me 10 log files, server.log.0 through server.log.9, each one up tp 500 KB in size. Thanks to EvilSeph's blog post, I was able to get version 1.7.2 to follow that behavior.

    I'm still testing it, but I figured I'd post what I have so far.

    I created this file http://pastebin.com/vNP9ePi1 as log4j2.xml and added the parameter -Dlog4j.configurationFile=log4j2.xml to the java command line. server.log.0 will then have the most recent log, with server.log.1 - server.log.9 having the successively older ones.

    Here are the important parts of the file, if you want to make your own customizations:

    log4j2.png

    Now I just have to figure out how to strip the color code escape sequences!

    EDIT: Looks like Bukkit 1.6 used this regex to strip the escape sequences:
    Code:
    "\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"
    
    I'll have to see if I can get log4j2 to strip out these matches.

    Success! This version includes the --log-strip-color functionality. Whoo-hoo! I have my old log format back.

    http://pastebin.com/vE7ginK3

    EDIT II: This is working beautifully. Logs are rolling over properly (after 500 K bytes) and all color codes are stripped. Just take this pastebin and name/reference as shown in EvilSeph's blog post, above.
     
  2. Offline

    seriosbrad

    Wonderful. Tested on my local server and it works great. I'm in contact with CreeperHost to see if I am allowed to modify the startup script as I could really use the striping for my live server.
     
  3. Offline

    Zhro

    Fantastic! I will test this when I get a chance. Do you know if leaving out SizeBasedTriggeringPolicy and DefaultRolloverStrategy will allow a single server log to grow to any size?
     
  4. Offline

    Bobcat00

    I believe so. At that point I think you simply have what EvilSeph posted in his blog. Although you could add the color code removal.
     
  5. Offline

    aredherring

    Does log4j support in-code configuration? I hate XML :(
     
  6. Offline

    Bobcat00

    I think you can use JSON instead.
     
  7. Offline

    aredherring

    In-code - not JSON: (
    in C# (log4net) we can configure the thing in-code but it's very messy
     
  8. Offline

    captbunzo

Thread Status:
Not open for further replies.

Share This Page