Questions about Logging

Posted by forral on Mon 17 May 2010 06:20 AM — 15 posts, 63,940 views.

USA #0
Hello,

I just had a few quick questions about logging.

1) Can a log file be set to automatically split up after X amount of lines? I often times reach 150-200k lines, and since I log in HTML color the logs could easily reach 10mb+.

2) I know there is an option to automatically log to a file, but it only allows .txt to be set as the file type. Obviously, an HTML file in .txt is pretty hard to decipher, and the person has to change the actual file extension. Could any client-side change be made to make this process a bit easier?

3) Also, I noticed the preamble on the log files (which I use to capture the timestamps) is off center by 1 line, by which I mean a cyan colored line has its corresponding timestamp 1 line down. Is there any way to fix this?

Thanks!
Forral
Australia Forum Administrator #1
forral said:

1) Can a log file be set to automatically split up after X amount of lines? I often times reach 150-200k lines, and


Not automatically, but you could make a timer that fires every 5 minutes. This could check the log file size (GetInfo (231)) and if over a limit you choose, it could close the log file and re-open it with an empty filename, which will then use the filename you define for automatic logging.

forral said:

I know there is an option to automatically log to a file, but it only allows .txt to be set as the file type.


You are referring to the file name chooser? Just manually replace the .txt in the box in the logging configuration to .html. I just did that and it worked fine.

forral said:

Also, I noticed the preamble on the log files (which I use to capture the timestamps) is off center by 1 line, by which I mean a cyan colored line has its corresponding timestamp 1 line down. Is there any way to fix this?


I don't think the preamble is off, it just doesn't get coloured, so it might *look* off. You might want to add into the preamble something to set a standard colour, eg.


<font color="lightgray">  (your timestamp) </font>


USA #2
Nick Gammon said:

forral said:

1) Can a log file be set to automatically split up after X amount of lines? I often times reach 150-200k lines, and


Not automatically, but you could make a timer that fires every 5 minutes. This could check the log file size (GetInfo (231)) and if over a limit you choose, it could close the log file and re-open it with an empty filename, which will then use the filename you define for automatic logging.

forral said:

I know there is an option to automatically log to a file, but it only allows .txt to be set as the file type.


You are referring to the file name chooser? Just manually replace the .txt in the box in the logging configuration to .html. I just did that and it worked fine.

forral said:

Also, I noticed the preamble on the log files (which I use to capture the timestamps) is off center by 1 line, by which I mean a cyan colored line has its corresponding timestamp 1 line down. Is there any way to fix this?


I don't think the preamble is off, it just doesn't get coloured, so it might *look* off. You might want to add into the preamble something to set a standard colour, eg.


<font color="lightgray">  (your timestamp) </font>






Thanks Nick. I will work on the timer tomorrow, and setting the preamble font color fixed my issue, as well as logging to .html.

The only other question, as I saw in another thread, is that is it possible to log to a different file each time? I can set the 'automatically log to this file' but it keeps appending to that file, which can get rather long...so is there any way for me to be able to split up files logging to log each time the client is open/closed, rather than each time I (dis)connect to the world? Perhaps later on down I will get good enough to sort each days' files automatically into their own folder.

Thanks,
Forral
Australia Forum Administrator #3
Build a timestamp into the log file name (click on the ? button to see the various options). Assuming you don't open a new log file every minute, a date/time to the nearest minute should do it.
Australia Forum Administrator #4
If you do that a simple timer to close the current log file, and open a new one, which fires every hour or two, might be all you need, to keep the files reasonably small.
USA #5
Once again, thank you Nick. This solution seems to be right for me, and now it is just a matter of tweaking it to my liking. Even though we play low-tech text-based games, we're just as picky as any other MMOers.

Thanks again!
Forral
USA #6
Nick Gammon said:
Just manually replace the .txt in the box in the logging configuration to .html. I just did that and it worked fine.


Maybe it's a bit of overkill, but here is my log settings in case anyone finds them useful.

Preamble:

<html>
 <head>
   <title>Log of %N session</title>
 </head>
 <body>
   <table border=0 cellpadding=5 bgcolor="#000000">
   <tr><td>
   <pre><code><font size=2 face="FixedSys, Lucida Console, Courier New, Courier">


Postamble:

</font></code></pre>
</td></tr></table>
</body>
</html>


I've checked on:
Log:
  Output
  Commands
  Notes

Format:
  HTML
  Colour

 Write World Name to Log File

Preamble of Output Lines:
<!--%#c-->





Also, I run MUSHClient from a command prompt, so upon closing it, I will call another script which will timestamp the log file.

It is called Stampme.cmd from http://ss64.com/nt/stampme.txt.

I've replaced the last three lines of the above-mentioned stampme.cmd with:

   ECHO Today is Day: [%_dd%] Month: [%_mm%] Year: [%_yy%]
   ECHO The time is:   [%_hr%]:[%_min%]
   REN "%_pathname%" "%_file%-%_yy%-%_mm%-%_dd% - %_hr%-%_min%%_ext%"


My own command script to run everything, assuming you stored Stampme.cmd in C:\Program Files\MUSHClient\logs and your run script is in C:\Program Files\MUSHClient:

@echo off
MUSHClient.exe
cd logs
Call Stampme.cmd Logfile.html


Edit:
Of course, the timestamping script only works when you actually exit MUSHClient..at least the way I've configured it, and thus will only reflect the date and time at that moment. Also, with that being said, it is recommended that one wait when closing out, as the script needs to initialise and run. I've come up with various mis-stamped files like Achaea-- - _-.html because I shut the computer off too quickly and the shutdown sequence interrupted the script before it had time to actually rewrite the filename.
Amended on Mon 17 May 2010 07:59 PM by Daniel P
USA #7
Well I have the logs kind of working, but MUSHclient for some reason doesn't like timestamping the log files each time. I get an error, upon start up, that says: Could not open log fine "C:\Porgram Files\MUSHclient\logs\forral 5/18/2010 12:41:27PM.html"

My settings are:
File preamble:
<html>
<head>
<title>%P - %A %c session</title>
</head>
<body>
<table border=0 cellpadding=5 bgcolor="#000000">

File postamble
</font></code></pre>
</td></tr></table>
</body>
</html>


Checkboxes are:
Logging output + commands, in HTML, color, and write world name to log file.

My directory is: C:\Program Files\MUSHclient\logs\%P %c.html

Output line preamble: <font color="lightgray">%I:%M:%S</font>

Command line premable: <font color="lightgray">%I:%M:%S</font>
USA #8
What OS? Vista and Win7 will smack you down for trying to write to Program Files if UAC is turned on.
USA #9
WillFa said:

What OS? Vista and Win7 will smack you down for trying to write to Program Files if UAC is turned on.


I've had limited success changing the permissions on the MUSHclient folder to get around this, but Windows likes to change it back as soon as I close the dialog. I have no idea what I did to avoid that, but these days I have MUSHclient in Documents/ anyways.
USA #10
I am encountering this problem while running Windows XP
USA #11
that why i installed mushclient in public/games/ folder to avoid the hassle. :)
#12
Heh, sorry for digging up this old topic, but here's two problems about logging.

My logs save in .html format, which works fine, colors are there, but...

1) The font of the savefile is bad, since the mud I play, had tiled map, and I've only found like 3 fonts that can show it correctly ingame. Would it be possible for the save file to automatically use the same font as in the world I play.

2) Linebreak doesn't work. This means that the log is in all one long line, making the whole thing gibberish.

I imagine I can fix the font myself, but is there a way to make the logs do linebreak, so like whenever there's a linebreak in the mud, it starts off with a new line in log?
The logs look perfect in .txt file, but in html it all gets jammed up together.

Hope you understand my concern. Any help appreciated.
Australia Forum Administrator #13
The HTML log will be a jumbled mess unless you use the "log file preamble" and "log file postamble" to put a bit of HTML around the lines.

There is a button in the logging configuration to do that automatically, and also see this post for an improved preamble/postamble:

http://www.gammon.com.au/forum/?id=10838

The important parts there are the font (so you get a monospaced font) and the <pre> ... </pre> parts which tell it to respect the line wrapping in the file.
#14
Yay, works now. Thanks a bunch.