Update files in tabs between restarts?

Feb 15, 2013 at 8:02 AM
Question: How can I make Log Expert load always the latest logfiles, even if it did not run during the logfile change?

I am using this great tool to have a tail look to about 6 Exchange 2010 Logfiles located in different folders below %ProgramFiles%\Microsoft\Exchange Server\V14\TransportRoles\Logs. With MultiFile I am able to follow changes of filenames around midnight. Filenames would change from i.e.
MSGTRK20130214-1.LOG to MSGTRK20130215-1.LOG. (using $D(YYYYMMDD) as mask).
That works fine as long as I let Log Expert running overnight.

However, if I close Log Expert in the evening and start it up in the morning, the new files are not added to the log. That is, if I have everything working fine on the 14th (MSGTRK20130214-1.LOG being the last file) and start Log Expert on the 15th, I would still only see MSGTRK20130214-1.LOG (the file that was active the day before). Even if the actual logfile is now the MSGTRK20130215-1.LOG.

I checked the session file and that contains the last filename hardcoded. So I guess it needs to be in Log Expert settings.

Currently, after I restart Log Expert on the new day, I need to manually load the logfiles again, enable MultiFile on each tab and click on Follow tail. It's not too much work, but it would be great to have this somewhat automated.

Is this possible?

Dan
Coordinator
Feb 19, 2013 at 5:13 PM
Sorry, it's not possible w/o code changes. At the time of implementing this multi file feature I only had to deal with log files that follows a naming style like

logfile.log
logfile1.log
logfile2.log

with beeing logfile.log always the most current file and greater numbers means older files.

All the date stuff was implemented later but I never really needed this. So it's not used in real life by myself - therefore not complete. :(

In the meantime I saw a lot of different crazy naming styles (e.g. by Glassfish and JBoss) which will not work with LogExpert's multi file. I would like to rewrite the multi file stuff but I have no time (and mood) for this.

Volunteers step forward! ;-)
Feb 19, 2013 at 5:35 PM
Well, what you provide on functionality already now is way more than I have seen in other similar software! Kudos :-)

Perhaps I adapt that script here http://logexpert.codeplex.com/discussions/361411 to do something closer.
But I guess I still have to manually enable the MultiFile option and the Tail option per tab/file.

Except if there is a hidden commandline option for this? ;-)

Dan
Coordinator
Feb 19, 2013 at 9:08 PM
Edited Feb 19, 2013 at 9:09 PM
No hidden command line option. :)

But if you're not afraid to patch some XML, you can play around with the *.lxp files (see "Persistence" tab in LogExpert's Settings). In the <options> tag there's an element <followTail enabled="1" />. You can lauch LogExpert with an LXP file on the command line. This will load the actual log file (see <file> element) and apply the options specified in the LXP.

LogExpert will also remember that the file was loaded from that specific LXP (will not apply the default LXP storage location). When closing the log file it will store the current file option set back into the LXP is was loaded from.

So you can copy and edit LXP file and use it to load log files with any option you want. You may also try to patch the file name for the current day into the LXP and activate multi file.
Coordinator
Feb 19, 2013 at 9:20 PM
Edited Feb 19, 2013 at 9:20 PM
Some more advanced multi file hacking: You can also specify the set of multi files manually in the LXP file. This will also work when the naming mask does not match:
<multifile enabled="1" pattern="*$J(.)" maxDays="3">
    <fileEntry fileName="C:\work\logs\logfile_A.txt" />
    <fileEntry fileName="C:\work\logs\logfile_with_some_other_naming.txt" />
</multifile>
This is the way LogExpert stores multi file sets when multiple files are loaded as one multi file (per default when dragging multiple files onto LogExpert while pressing down the shift key).
Feb 20, 2013 at 8:55 PM
Edited Feb 20, 2013 at 9:03 PM
Thanks to your inputs. I've wrote something up. Please note that I am not a programmer, so this looks quite rough and could be easily simplified and improved (i.e. just one for-loop... anyway.

Basically it works.
However, MultiFile does not work consistently:
  • If I load the created startfile.lxj session (which lists several logfiles) in LogExpert, MultiFile is NOT enabled. Follow Tail is enabled.
  • MultiFile is enabled on all tabs/files however, if I had it enabled manually on each tab, then closed all tabs, then loaded the startfile.lxj session file.
  • I believe this is somewhat related to the persistens switch. If "Automatically save persistence file (.lxp)" is selected/enabled, the MultiFile setting is always taken from the persistence .lxp files. The MultiFile settings in my .lxp files I've created with the script below, are not considered.
  • Oh, and I just verified that if persistence is switched off, the Multifile option in my .lxp fiels are not working either. That looks like this in my files:
    <options>
      <multifile enabled="1" pattern="*$D(YYYYMMDD)*" maxDays="3" />
      <followTail enabled="1" />
    </options>
I have played around with the persistence .lxp file to figure out what the minimum content is to make it work. See below the template .lxp file. However, that only seem to work if the file is the persistence file... Hmm..

Is this a bug?

Dan


here is the script. It is in PowerShell:
#################################################################################
# 
# Prepares startup files for LogExpert
# Exchange Logfiles
#
#################################################################################
# Written by Daniel Huber
# Version .02 130220
## 
#
$TempDir = $env:temp
$TemplateFile = ".\LogFile_Template.lxp"
$Temp_lxj = ".\startfile.lxj"
#
$Placeholder_FILENAME = "@FILENAME@"
$Placeholder_TABNAME = "@TABNAME@"
$Placeholder_DATE = "@@@"
#
# Those are the logfiles I want to monitor in LogExpert
# @@@ is a placeholder for todays date
#
$LogFiles = @{
"AgentLog"  = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\AgentLog\AgentLog@@@-1.LOG";
"SEND"      = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\ProtocolLog\SmtpSend\SEND@@@-1.LOG";
"MSGTRKM"   = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\MessageTracking\MSGTRKM@@@-1.LOG";
"RECV"      = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\ProtocolLog\SmtpReceive\RECV@@@-1.LOG";
"MSGTRK"    = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\MessageTracking\MSGTRK@@@-1.LOG";
"CONNECTLOG" = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\Connectivity\CONNECTLOG@@@-1.LOG"
}
#
# get todays date
$MyDate = get-date -Format yyyyMMdd
#
# Create .lxp files
foreach($key in $($LogFiles.keys)){
    $LogFiles[$key] = $LogFiles[$key] -replace "$Placeholder_DATE","$MyDate"
    $LogFiles[$key]
    (gc "$TemplateFile") -replace "$Placeholder_FILENAME",$LogFiles[$key] -replace "$Placeholder_TABNAME","$key" > .\"$key".lxp
}
#
# creating .lxj file
Write-Output "<logexpert><project><members>" > $Temp_lxj
foreach($key in $($LogFiles.keys)){
    $line = '<member fileName="' + $LogFiles[$key] + '" />'
    Write-Output $line >> $Temp_lxj
}
Write-Output "</members></project></logexpert>" >> $Temp_lxj
#
The template file LogFile_Template.lxp looks like this. Stripped down to the (almost) minimum, tested as persistence file...
<logexpert>
  <file fileName="@FILENAME@">
    <bookmarks />
    <rowheights />
    <options>
      <multifile enabled="1" pattern="*$D(YYYYMMDD)*" maxDays="3" />
      <followTail enabled="1" />
    </options>
    <tab name="@TABNAME@" />
    <columnizer name="Default (single line)" />
    <highlightGroup name="[Default]" />
    <filters>
      <filter>
      </filter>
    </filters>
    <encoding name="utf-8" />
  </file>
</logexpert>
Coordinator
Feb 21, 2013 at 4:36 PM
I am not sure if I did understand the situation correctly. But try following:

Create an .lxj file which contains file entries to your .lxp files created by your template processor.
E.g.
<logexpert>
  <project>
    <members>
      <member fileName="c:\tmp\file1.lxp" />
      <member fileName="c:\tmp\file2.lxp" />
    </members>
  </project>
</logexpert>
Here are some rules:
  • When loading the .lxj with LogExpert it will load the log files from all the .lxp and apply the options.
  • This also works if persistence saving is switched off in LogExpert.
  • When persistence saving is switched off, LogExpert will not save changes to the .lxp files automatically.
  • If you manually save the session (.lxj) (via "File"->"Save session...") then writing of the .lxp files will be forced even when persistence saving is disabled.
  • Persistence saving always save into the .lxp it was loaded from. So if you supply own .lxp files (e.g. created by your script) AND you have loaded the log file by using the .lxp then this .lxp is used. Regardless of the persistence settings.
Feb 21, 2013 at 7:04 PM
Ahhh...
I wrote the wrong stuff into the .lxj file. Thanks for the reminder.
How do we say in German? Man sieht den Wald vor lauter Bäumen nicht...

Now all works as expected. Corrected script is attached below.

Thanks Hagen

Dan
#################################################################################
# 
# Prepares startup files for LogExpert
# Exchange Logfiles
#
#################################################################################
# Written by Daniel Huber
# Version .03 130221
## 

# get todays date
$MyDate = get-date -Format yyyyMMdd
$TempDir = $env:temp
$TemplateFile = ".\LogFile_Template.lxp"
$Temp_lxj = "startfile.lxj"
$LogExpert = "..\LogExpert.exe"

$Placeholder_FILENAME = "@FILENAME@"
$Placeholder_TABNAME = "@TABNAME@"
$Placeholder_DATE = "@@@"

$LogFiles = @{
"AgentLog"  = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\AgentLog\AgentLog@@@-1.LOG";
"SEND"      = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\ProtocolLog\SmtpSend\SEND@@@-1.LOG";
"MSGTRKM"   = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\MessageTracking\MSGTRKM@@@-1.LOG";
"RECV"      = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\ProtocolLog\SmtpReceive\RECV@@@-1.LOG";
"MSGTRK"    = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\MessageTracking\MSGTRK@@@-1.LOG";
"CONNECTLOG" = "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Logs\Connectivity\CONNECTLOG@@@-1.LOG"
}

# Create .lxp files
foreach($key in $($LogFiles.keys)){
    $LogFiles[$key] = $LogFiles[$key] -replace "$Placeholder_DATE","$MyDate"
    $LogFiles[$key]
    (gc "$TemplateFile") -replace "$Placeholder_FILENAME",$LogFiles[$key] -replace "$Placeholder_TABNAME","$key" > $TempDir\"$key".lxp
}

# creating .lxj file
Write-Output "<logexpert><project><members>" > $TempDir\$Temp_lxj
foreach($key in $($LogFiles.keys)){
    $line = '<member fileName="' + $TempDir + '\' + $key + '.lxp" />'
    Write-Output $line >> $TempDir\$Temp_lxj
}
Write-Output "</members></project></logexpert>" >> $TempDir\$Temp_lxj

#
# Start LogExpert
Start-Process $LogExpert $TempDir\$Temp_lxj